In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the differences between PHP and ASP.NET in the implementation and management mechanism of Session". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Session article:
PHP uses files to store session data by default, and asp.net is stored in IIS process memory by default.
Advantages of PHP mode: stable and reliable not easy to lose, nginx or apache server restart does not affect session loss, session is stable and reliable. The whole mechanism is simple and transparent, and the user can directly delete the files in the session directory to invalidate the session. It can easily achieve some special requirements that are difficult for asp.net to achieve, such as the need to invalidate the specified A user session after the user's request or some events in the system, and then must force the latest records to be read from the database. If there is such a contradictory performance optimization scenario design: if the user table User has a balance field Balance, to let user A log in to his backend to see that his balance is up-to-date, and do not want to request a database every time the face is refreshed to cause unnecessary pressure, the best way is to save a user's record entity in Session and read his balance field from Session to display each time. Will not put pressure on the database, only when the balance field Balance changes immediately clear the user's Seesion and then force him to read the latest database fields, but when other events occur, such as: other users to An after the transfer of money to clear A cache, system refund, deduction, reward to the balance caused by changes in the cache to clear A, because the transparent mechanism of php can directly delete the corresponding session file But using iis is very troublesome, because Microsoft prefers session to be put in memory, it is tragic that it is closed into a black box and does not provide corresponding operation interface, only through other ways to save the country by curve.
Disadvantages of PHP method: poor performance is not as fast as saving in memory, and a large number of small files are generated. Repeatedly creating and deleting these small files will cause disk fragments to slow down the performance of the entire disk over time, resulting in a large number of file handles occupying operating system file handles, which in turn affect performance. The increase in website visits is a tragedy, which may produce millions of small files in one directory. Even running on an operating system like linux, where everything is a file idea, also has a great impact on file system performance, which will seriously depress the disk performance of the entire operating system. Therefore, the performance of this default mechanism is not as fast as IIS's default storage in process storage. Those who boast that the performance design of open source technology is more advanced than windows hit their own faces. Recently, after an in-depth understanding of lamp,lnmp, they found that many outdated designs can not keep up with the times, such as the inability of php to use real database connection pooling, and many more serious problems than originally imagined. Of course, there will be third-party alternative alternatives, such as using memcache memory to save session in memory. But it needs to be done by hand.
PHP distributed session support: in a highly concurrent multi-server load balancing environment, two nginx or apache generally save session in a database to share the session, and then different load hosts connect to a database. There is no essential difference between database performance and reading and writing files, and stability is still strong, but performance is still a weakness.
Advantages of ASP.NET: high speed, no need to read or write disks. Obviously, this is very natural.
Disadvantages of ASP.NET approach: very unstable, not to mention extreme operations such as restarting the IIS website will lose Session, even if you change the configuration file web.config or change the dll in the bin directory to cause the website to recompile, the memory will be reset and the Session will be lost. This is why during the start of asp.net debugging, we often encounter the strange illusion that the session may be lost in a few seconds when the tester logs on to the system. Generally speaking, programmers update programs frequently, and as long as they update them once, they will lose their session completely. Microsoft's solution is simple and easy to use, using a separate ASP.NET State Service state service process to save session information. Note that after using ASP.NET State Service, the data is still stored in memory, but a separate service process. By default, the information is saved by listening to the tcpip=127.0.0.1:42424 port for cross-process communication.
In this way, even if IIS is restarted, it will not cause users to log in to session, and the stability is solved. At the same time, the data is saved in a file storage scheme whose performance is much higher than that of php. And the status service is installed by default on every computer, as long as it is started. Convenience and performance are no longer at the same level as php.
Implementation of ASP.NET distributed session: in a highly concurrent multi-server load balancing environment, it is very simple for two IIS to share session. They only need to connect to a state server together to share session. Through simple settings, the status service can turn on the remote access function. Of course, asp.net also supports saving session to a database, but few people use it this way and there is no great reason to adopt this scheme.
This is the end of the content of "what are the differences between PHP and ASP.NET in the implementation and management mechanism of Session". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.