Website performance improvement experience

Time:2019-10-21

DB:
1. The database can properly design some redundant fields to reduce the joint query
2. Frequently queried fields should be indexed
3. The query content should be as simple as possible. For example, set $this – > recursive = – 1 for the query in CakePHP, and specify fields.
4. The database uses a separate server, and the common query data with conditions is separately stored.
5. Putting session and other data in Memcache instead of database can not only satisfy the sharing among multiple servers, but also reduce the load of database.
Refer to the following article: http://www.linuxjournal.com/article/7451? Page = 0,1
6. Bad SQL will destroy the CPU of the system, especially when using in query, make sure that the data in array is unique and cannot have a large amount of data.
HTTP Request:
1. Adjust Apache to increase the number of concurrent server processing connections
2. Compress JS / CSS to reduce the number of concurrent requests (gzip configuration of Apache / nginx)
3. Try to use offline database and call less remote HTTP service (geoip service, Google Map…). At least set a reasonable request timeout.
4. Dedicated server for pictures and static resources
WEB server:
1.apache+php->ningx+(php+fpm)
2. Haproxy, set request queue, such as 50, which can buffer and protect web server, with obvious effect.
3. Add Web server, haproxy load balancing
(note that the session / cache of multiple servers should be placed in the database or Memcache, the code patches should be synchronized, and the dynamically generated or administrator loaded resources should be synchronized.)
Code:
1. Avoid invalid cycle
2. Avoid invalid link requests
3. Do not generate single server files in design
4. Pay attention not to generate a large number of small files in the design, otherwise, inode resources may be exhausted.
5. In terms of design, we should not confuse the sending of a large number of marketing emails with a single business email. In addition, the generating and sending logic of bulk emails should be separated.
6. It is better to send marketing email in the form of calling a third-party professional email service. This avoids spam and checks for invalid messages
to be continued.