简体   繁体   English

高性能集中式PHP session存储

[英]High-performance centralized PHP session storage

My application can store up to dozens or even low hundreds of KB of data in the session.我的应用程序可以在 session 中存储多达几十甚至几百 KB 的数据。 I'm currently storing PHP sessions in MySQL blobs, and traffic volume is now putting session-related queries on the database around 25-75 per second.我目前正在 MySQL blob 中存储 PHP 会话,并且流量现在正在以每秒 25-75 个左右的速度将会话相关的查询放在数据库中。 It's causing some problems.它造成了一些问题。

Is there a centralized storage option for PHP sessions of this size that will perform well?对于这种大小的 PHP 会话,是否有一个可以很好地执行的集中存储选项? I'd prefer to avoid sticky sessions at the load-balancer level if possible for other performance reasons.出于其他性能原因,如果可能的话,我宁愿避免在负载均衡器级别出现粘性会话。 I can try to reduce the session size, but regardless I'm going to need this information on most requests, so I'm going to have to stash it somewhere.我可以尝试减小 session 的大小,但无论如何我在大多数请求中都需要这些信息,所以我必须把它藏在某个地方。

Scache is ideal for that. Scache是理想的选择。 You can probably split your session data to smaller parts, some might even be cacheable to all sessions and so on.您可能可以将 session 数据拆分为更小的部分,有些甚至可以缓存到所有会话等等。 Scache has api for all that. Scache 拥有 api。

There's nothing bad in big session data, it's bad only if you store it to $_SESSION.大的 session 数据没有什么不好,只有将它存储到 $_SESSION 时才不好。

memcached is always a favorite option. memcached始终是最受欢迎的选项。

The memcache PHP extension helpfully comes with a session handler that will store sessions with memcached. memcache PHP 扩展附带一个 session 处理程序,该处理程序将存储与 memcached 的会话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM