每个用户有多少个会话变量被认为太多了?PHP -

时间:2022-09-20 11:13:53

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?

如果我有一个网站,用户登录和注销,每个用户有4个会话变量,这将如何影响我的网站?

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.

假设我有10万活跃成员,那么实际上同时传递了40万个会话变量。这会影响我网站的加载吗?我理解php有一个内存限制,但还没有完全理解它。

Thanks

谢谢

3 个解决方案

#1


6  

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)

每个用户4个变量没什么,但我的建议是在不同的层次上:关注导致网站瓶颈的真正原因。这个问题现在可能不相关,如果这让你慢下来的话,将来很容易就会改变。(也不会)

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!

我敢打赌你有比担心另一个变量更重要的事情要做,当你有这么多活跃的用户时,你的整个结构可能会改变,包括服务器和解决方案。好运!

#2


1  

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.

简短回答——是的,如果你有10万用户,它将影响你的站点的加载。但这不只是因为会话,它们将成为瓶颈的一部分。

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.

此外,使用默认的PHP配置(尤其是会话配置),您不会在单个服务器上部署具有如此多活动用户的站点。

#3


0  

The answer, of course, is "it depends".

答案当然是“视情况而定”。

STRONG SUGGESTION:

强烈建议:

1) Establish a "performance baseline"

1)建立“绩效基线”

2) Consider resources like CPU, memory, network and disk

2)考虑CPU、内存、网络和磁盘等资源

3) Consider OS, Web server, Application and database

3)考虑操作系统、Web服务器、应用程序和数据库

4) Run stress tests, and compare your performance between "normal loads" to "high loads"

4)运行压力测试,比较“正常负载”和“高负载”之间的性能

5) Identify the bottlenecks, and deal with them appropriately

5)识别瓶颈,并妥善处理。

Assuming you're running Linux/Apache/MySql (a total guess on my part - you didn't say), here's an excellent three-part article that might get you started in the right direction:

假设您正在运行Linux/Apache/MySql(这完全是我的猜测——您没有说),这里有一篇精彩的三部分文章,可能会让您朝正确的方向开始:

But trust me: worrying about minutia like whether you have 5 session variables instead or 4, instead of trying to gather solid baseline statistics, is NOT going to help you scale to 100,000 users :)!

但请相信我:担心一些细节,比如你是否有5个会话变量而不是4个会话变量,而不是试图收集可靠的基线统计数据,并不能帮助你扩展到10万用户:)!

#1


6  

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)

每个用户4个变量没什么,但我的建议是在不同的层次上:关注导致网站瓶颈的真正原因。这个问题现在可能不相关,如果这让你慢下来的话,将来很容易就会改变。(也不会)

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!

我敢打赌你有比担心另一个变量更重要的事情要做,当你有这么多活跃的用户时,你的整个结构可能会改变,包括服务器和解决方案。好运!

#2


1  

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.

简短回答——是的,如果你有10万用户,它将影响你的站点的加载。但这不只是因为会话,它们将成为瓶颈的一部分。

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.

此外,使用默认的PHP配置(尤其是会话配置),您不会在单个服务器上部署具有如此多活动用户的站点。

#3


0  

The answer, of course, is "it depends".

答案当然是“视情况而定”。

STRONG SUGGESTION:

强烈建议:

1) Establish a "performance baseline"

1)建立“绩效基线”

2) Consider resources like CPU, memory, network and disk

2)考虑CPU、内存、网络和磁盘等资源

3) Consider OS, Web server, Application and database

3)考虑操作系统、Web服务器、应用程序和数据库

4) Run stress tests, and compare your performance between "normal loads" to "high loads"

4)运行压力测试,比较“正常负载”和“高负载”之间的性能

5) Identify the bottlenecks, and deal with them appropriately

5)识别瓶颈,并妥善处理。

Assuming you're running Linux/Apache/MySql (a total guess on my part - you didn't say), here's an excellent three-part article that might get you started in the right direction:

假设您正在运行Linux/Apache/MySql(这完全是我的猜测——您没有说),这里有一篇精彩的三部分文章,可能会让您朝正确的方向开始:

But trust me: worrying about minutia like whether you have 5 session variables instead or 4, instead of trying to gather solid baseline statistics, is NOT going to help you scale to 100,000 users :)!

但请相信我:担心一些细节,比如你是否有5个会话变量而不是4个会话变量,而不是试图收集可靠的基线统计数据,并不能帮助你扩展到10万用户:)!