Summary of. net's plan to deal with the pressure of website access

  • 2021-09-11 19:58:12
  • OfStack

The beginning of the year is relatively empty, take time to write a blog post, and summarize some technical solutions to deal with the pressure of website access in your work.

My own project is now about 1 day 50W pv. I have summarized my own solutions from front-end to back-end.

1. Front-end page:

1. First of all, reduce the size of resources. If you can use small pictures, use small pictures. Refer to the third party js and use mini compressed version js.

2. Use CDN to reduce the pressure of server access, and put pictures, css and js files on CDN. Users can get resources from the cdn cache much faster than accessing the server. (There is also network relationship, cdn network is fast)

3. The time-consuming js can be loaded after asynchronous request.

2. Server load balancing:

There are many load balancing solutions, not bad money, not bad money, silk has silk solutions. I use nginx load balancing.

Prepare a dedicated nginx load balancing server, use it for load balancing, and forward it to 5 business servers. (When development requires single debugging, point to single with hosts)

3. Server caching

Because of the distributed architecture, the server cache mainly uses memcached and redis (each configured with 2, 1 main service and 1 standby). Both memcached and redis have their own. net versions, which are not complicated to use.

Specific choice depends on business requirements, I basically use memcached for 70%, and use redis for long-term cache.

memcached for Chinese support is not good, to store Chinese data, the first Chinese base64 encoding in the storage, read time to do base64 decoding.

4. Database

I mainly use sqlserver, and a few projects use mysql. 50W visits can be fully supported by a single sqlserver server. Minimize transactions, and the business needs to be supplemented by message queuing.

Large task sites are not handled, but are handled by other programs (in response to demanding modifications, the redis cache is modified first, and then the database is operated by asynchronous programs.)

Log is recorded during operation, database crash or website crash can read log file to supplement data operation. (1 server will not hang up for a long time, and it can't be restored for more than 1 day. It's really looking at the specific situation to find a solution)


Related articles: