Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many session variables per user is considered too much? - PHP

Tags:

php

session

If I have a website where users login and logout, and each user has 4 session variables being used, how will this affect my site?

Say if I have 100,000 active members, then that would be effectively 400,000 session variables being passed at the same time. Will this affect the loading of my site? I understand php has a memory limit but do not fully understand it.

Thanks

like image 275
nvcode Avatar asked Oct 15 '11 18:10

nvcode


2 Answers

4 variables per user is nothing, but my suggestion would be on a different level: Focus on what's causing actual bottlenecks in your web site. This issue is probably not relevant right now, and is really easy to switch from in the future if this what slows you down. (And it won't)

I bet you have much more important stuff to work on than worry about another variable, and when you get to that amount of active users, your whole structure will probably change, including servers and solutions. Good luck!

like image 70
Dvir Avatar answered Sep 20 '22 03:09

Dvir


To answer shortly - yes, it will affect loading of your site, if you have 100k users. But it won't be only because of sessions, they will be a part of the bottleneck.

It's easy to calculate possible memory consumption and according to that you should decide how to scale your site. Scaling options are endless (well, as a phrase of course, there's a finite amount of ways to scale programs but still there are many to choose).

If it happens that you attract that many users, chances are you will be able to afford professional help when it comes to scaling your site.

If it's a case of you wondering what those options are, then it might be the best to ask a question with specific things in mind that trouble you when determining when and where the bottlenecks might be.

Also, you don't deploy sites with so many active users on a single server, using default PHP configuration, especially the session one.

like image 38
Furicane Avatar answered Sep 22 '22 03:09

Furicane