Suppose we have a website with 100k active users.
假设我们有一个拥有10万活跃用户的网站。
If we want to save email, name, last name and gender of users in sessions, how much space is allocated to all the sessions?
如果我们想在会话中保存用户的电子邮件,姓名,姓氏和性别,那么为所有会话分配了多少空间?
Are the sessions affecting server RAM, server bandwidth or something else?
会话是否影响服务器RAM,服务器带宽或其他?
Please give me a little information about session functionality and effect of session overload on the server.
请给我一些关于会话功能和服务器上会话过载影响的信息。
3 个解决方案
#1
4
The session themselves will consume the server RAM if your mode is set to InProc
, which is limited only by the amount of RAM available to the worker process.
如果您的模式设置为InProc,则会话本身将使用服务器RAM,InProc仅受工作进程可用的RAM数量的限制。
Considering your high demand, you want to be really careful what you're putting in the session, only when it's absolutely necessary. Don't put things in session and leave them there for use in a page or two, just go back to the database and get them, otherwise your session size will creep up drastically.
考虑到你的高要求,你要非常小心你在会话中所做的事情,只有在绝对必要的时候。不要把东西放在会话中并留在那里用于一两页,只需返回数据库并获取它们,否则会话大小将大幅增加。
Based on what you're storing, it's only 5kb or even less, so based on 100k users, that would be:
根据您存储的内容,它只有5kb甚至更少,因此基于100k用户,这将是:
5kb * 100,000 = 488.28MB
So you see, even though you're only storing a couple of details, at that level of usage the memory usage is quite significant.
所以你看,即使你只存储了一些细节,在这个使用级别,内存使用量也是非常重要的。
For such high demand and usage, I would consider using a dedicated state server (StateServer
mode) which allows you to manage it separately and allocate the resources to that server as required.
对于如此高的需求和使用,我会考虑使用专用的状态服务器(StateServer模式),它允许您单独管理它并根据需要将资源分配给该服务器。
The other option is using SQL Server session (SQLServer
mode) which is limited only by the size that is available to the database. So we're talking hard disk space here and not RAM. To be honest though, if you're going to the database to retrieve your session information, then why not just go to the database and retrieve the information you need anyway?
另一个选项是使用SQL Server会话(SQLServer模式),该会话仅受数据库可用的大小限制。所以我们在这里谈论硬盘空间而不是RAM。说实话,如果你要去数据库检索你的会话信息,那么为什么不去数据库并检索你需要的信息呢?
#2
1
I would recommend you to store such data in the client when you have 100k users. Your pages will be larger and require more bandwidth but you will allocate less memory on the server. If you talking about a ASP-application check this article http://www.codeproject.com/Articles/416137/Understanding-Session-Management-Techniques-in-ASP
当你有100万用户时,我建议你在客户端存储这些数据。您的页面会更大,需要更多带宽,但您将在服务器上分配更少的内存。如果您在谈论ASP应用程序,请查看本文http://www.codeproject.com/Articles/416137/Understanding-Session-Management-Techniques-in-ASP
#3
1
NOTE:
注意:
This answer was posted when the OP asked about php and asp.net
这个答案是在OP询问php和asp.net时发布的
Are the sessions affecting server RAM, server bandwidth or something else?
会话是否影响服务器RAM,服务器带宽或其他?
Sessions are affecting server RAM
会话正在影响服务器RAM
Please give me a little information about session functionality and effect of session overload on the server.
请给我一些关于会话功能和服务器上会话过载影响的信息。
If the effect of sessions overload the server, the server will run slow because of the usage of the RAM.
如果会话的影响使服务器超载,则由于RAM的使用,服务器将运行缓慢。
Most of the settings of sessions can be changed in the php.ini file
可以在php.ini文件中更改会话的大多数设置
If you want to know more about session functionality, you should check out the pages about sessions on php.net or even the wiki.
如果您想了解有关会话功能的更多信息,您应该查看有关php.net甚至维基上的会话的页面。
There is too much information about sessions to actually post in an answer.
关于在答案中实际发布的会话的信息太多了。
#1
4
The session themselves will consume the server RAM if your mode is set to InProc
, which is limited only by the amount of RAM available to the worker process.
如果您的模式设置为InProc,则会话本身将使用服务器RAM,InProc仅受工作进程可用的RAM数量的限制。
Considering your high demand, you want to be really careful what you're putting in the session, only when it's absolutely necessary. Don't put things in session and leave them there for use in a page or two, just go back to the database and get them, otherwise your session size will creep up drastically.
考虑到你的高要求,你要非常小心你在会话中所做的事情,只有在绝对必要的时候。不要把东西放在会话中并留在那里用于一两页,只需返回数据库并获取它们,否则会话大小将大幅增加。
Based on what you're storing, it's only 5kb or even less, so based on 100k users, that would be:
根据您存储的内容,它只有5kb甚至更少,因此基于100k用户,这将是:
5kb * 100,000 = 488.28MB
So you see, even though you're only storing a couple of details, at that level of usage the memory usage is quite significant.
所以你看,即使你只存储了一些细节,在这个使用级别,内存使用量也是非常重要的。
For such high demand and usage, I would consider using a dedicated state server (StateServer
mode) which allows you to manage it separately and allocate the resources to that server as required.
对于如此高的需求和使用,我会考虑使用专用的状态服务器(StateServer模式),它允许您单独管理它并根据需要将资源分配给该服务器。
The other option is using SQL Server session (SQLServer
mode) which is limited only by the size that is available to the database. So we're talking hard disk space here and not RAM. To be honest though, if you're going to the database to retrieve your session information, then why not just go to the database and retrieve the information you need anyway?
另一个选项是使用SQL Server会话(SQLServer模式),该会话仅受数据库可用的大小限制。所以我们在这里谈论硬盘空间而不是RAM。说实话,如果你要去数据库检索你的会话信息,那么为什么不去数据库并检索你需要的信息呢?
#2
1
I would recommend you to store such data in the client when you have 100k users. Your pages will be larger and require more bandwidth but you will allocate less memory on the server. If you talking about a ASP-application check this article http://www.codeproject.com/Articles/416137/Understanding-Session-Management-Techniques-in-ASP
当你有100万用户时,我建议你在客户端存储这些数据。您的页面会更大,需要更多带宽,但您将在服务器上分配更少的内存。如果您在谈论ASP应用程序,请查看本文http://www.codeproject.com/Articles/416137/Understanding-Session-Management-Techniques-in-ASP
#3
1
NOTE:
注意:
This answer was posted when the OP asked about php and asp.net
这个答案是在OP询问php和asp.net时发布的
Are the sessions affecting server RAM, server bandwidth or something else?
会话是否影响服务器RAM,服务器带宽或其他?
Sessions are affecting server RAM
会话正在影响服务器RAM
Please give me a little information about session functionality and effect of session overload on the server.
请给我一些关于会话功能和服务器上会话过载影响的信息。
If the effect of sessions overload the server, the server will run slow because of the usage of the RAM.
如果会话的影响使服务器超载,则由于RAM的使用,服务器将运行缓慢。
Most of the settings of sessions can be changed in the php.ini file
可以在php.ini文件中更改会话的大多数设置
If you want to know more about session functionality, you should check out the pages about sessions on php.net or even the wiki.
如果您想了解有关会话功能的更多信息,您应该查看有关php.net甚至维基上的会话的页面。
There is too much information about sessions to actually post in an answer.
关于在答案中实际发布的会话的信息太多了。