In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to use ASP.NET session storage mode, the content is very detailed, interested in small partners can refer to, I hope to help you.
ASP.NET Session storage method is not as simple as asp, a total of three storage methods, due to the recent failure of a web software used by more than 2000 people, users every morning at a certain time difficult to log in phenomenon, then the session value appears, only restart IIS, or machine. At this point the program reverts to normal. The same problem doesn't occur all day, but the next day it's still the same! This phenomenon lasted for several days, I checked the log file, the peak number of visitors per second is about 20 people, at the same time about 100 people online, the number of visitors will increase in the future, in order to solve this strange problem, first from the software, so three ways have been applied.
Open the web.config file
< sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20" />The default mode is InProc type, this mode is the same as ASP mode before, that is, the server stores Session information in IIS process, when IIS is closed and restarted, these process information will be lost, but the performance of this mode **(specific not tested, said in the book), this mode is the default mode of asp.net.
Because this mode failed, my consideration at the time was that the Inetinfo.exe process crashed due to excessive traffic. It is difficult for users to log in, so that the session value is lost. I use another Session storage method to store the Session information outside the process.
First, open the admin tool to find the service, find the service named: asp.net State Service, and start it. And changed to automatic start. At this point you can see a process called aspnet_state.exe in Task Manager. This is how we save session information.
Then, go back to the web.config file and change the value of Mode to StateServer, saving the file. OK.
< sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=192.10.78.76;User id=sa;password=sa" cookieless="false" timeout="20" />In this mode, when we restart IIS, the saved session values are not lost. In addition, this method can also save the information in the process of other machines, but also change stateConnectionString="tcpip=127.0.0.1:42424",IP address to other machines.
Other measures have also been taken. For example, separate the database from the Web server, the database server does not provide Web services, the Web server does not provide database services,
Then I expanded the connection pool. Since the default number of connection pools for ADO. NET data access in ASP.NET is 100, I later expanded it to 6000 by the way.
"Server=(local);Database=rgs;password=sa;user ID=sa;Max Pool Size =6000; Min Pool Size =5;Pooling=True"
*** Change memoryLimit in ProcessModel in Machine.config to 95, default to 60, indicating that iis process will automatically restart after memory consumption exceeds 60%. Then I also wrote some other ways to optimize IIS, increase the IIS cache of the registry, and so on.
When I finished these optimization steps, the whole software runs relatively well, the next day did not find the phenomenon of congestion, but the third day the situation appeared again, there is no way, I took a *** ASP.NET session storage method is stored in SQL Server, I think this stability should be stronger.
To use SQL Server, first run InstallSqlState.sql or InstallPersistSqlState.sql (default location:systemroot\Microsoft. NET\Framework\versionNumber below) on the session-state SQL Server computer. Both scripts create a database named ASPState. The difference between the two scripts lies in where the ASPStateTempApplication and ASPStageTempSessions tables are placed. The InstallSqlState.sql script adds these tables to the TempDB database, which loses data when the computer restarts, and the InstallPersistSqlState.sql script adds these tables to the ASPState database, which retains session data when the computer restarts.
Then in the application's web.config file, put
< sessionState>Set the mode attribute of the element to SQL Server,*** Set the sqlConnectionString attribute to Integrated Security=SSPI;data source=serverName;
< sessionState mode="SQLServer" sqlConnectionString=" Integrated Security=SSPI;data source=dataserver;" cookieless="false" timeout="20"/> < /sessionState>If deployed on other machines can be changed to, plus username and password
< sessionState mode="SQLServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=192.10.78.76;User id=sa;password=sa" cookieless="false" timeout="20" />This deployment is complete, if you do not want to use this can be deleted, as long as the corresponding directory (systemroot\Microsoft. NET\Framework\versionNumber) to find UninstallPersistSqlState.sql or UninstallSqlState.sql file can be run. This introduces the session storage mode in ASP.NET.
It should be noted that, whether using StateServer or SQL Server mode, when using session conversion objects, pay attention to serializing the objects first, that is, adding Serializable before the class, otherwise an error will occur!
About how to use ASP.NET session storage mode to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.