Custom session storage mechanism to avoid session persistence problems

Source: Internet
Author: User
The PHP server session is stored as a file. when the user's access volume is too large, the session persistence problem will occur. the following two solutions are available, you can refer to the PHP server session to store files. when the user's traffic is too large, there will be a lot of session files, and when the server is added horizontally, the session files cannot be synchronized, session persistence issues.

There are two solutions:

1. use NFS or Samba file sharing to share session files on a single server to solve the problem of session non-synchronization during server load balancer. (However, the efficiency issue cannot be solved. if there are tens of thousands of session files, the query will be slow)

2. session is stored in the database. other servers can share the database server to solve the session problem. at the same time, the database also solves the file efficiency problem. Databases can be scaled horizontally to solve both speed and volume issues.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.