Hey,
I am building a website that will likely host 10,000+ users with screen names who will be logged in and use
the site often. One key function is using Geo IP where I can pull their city/state and that data comes in handy
every time they answer a poll question or view results. Long story short, I was thinking that instead of using the DB
to pull that data every so often for a user, I should simply load those values into a session when they log in.
This way, if 10,20,50K++ users ever are at the site at once it's not hitting the DB each time I need to filter poll results
based on their city or state. By using a session which pulls these values only once during log-in, I am not needlessly
hitting the db over and over agian.
Thoughts?
Thank you for your time.
Debating Using Sessions To Save DB Load...Thoughts?
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Debating Using Sessions To Save DB Load...Thoughts?
You can certainly do that. But if you go to a distributed architecture, you will end up with database based sessions and be back to the same problem. Perhaps putting these values in a cookie would be a good solution.
(#10850)
Re: Debating Using Sessions To Save DB Load...Thoughts?
How about abstracting "finder" / "locator" services for each domain entity, later on you can "jimmy" in a cache layer if it is deemed necessary.
- PHPHorizons
- Forum Contributor
- Posts: 175
- Joined: Mon Sep 14, 2009 11:38 pm
Re: Debating Using Sessions To Save DB Load...Thoughts?
Hello jbh, the only thing I'd add is that, if you are already starting sessions for your users, then there is still a savings by storing that data in a session instead of querying on each page load.
The session data is queried anyways, so by not querying this geo ip data on each page load, you are saving a lot of queries, even with db sessions.
The session data is queried anyways, so by not querying this geo ip data on each page load, you are saving a lot of queries, even with db sessions.
Re: Debating Using Sessions To Save DB Load...Thoughts?
I haven't found the Geo-IP extension to be particularly slow. I may be reading it on every request in one application. Now I'm gonna have to check.
10K simultaneous users? You sure you'll have that many?
I'd way until the performance is measurably a problem before trying to fix it.
10K simultaneous users? You sure you'll have that many?
I'd way until the performance is measurably a problem before trying to fix it.