Website performance tuning practice-learning with KuangStudy

How do we optimize the performance of KuangStudy website in the face of concurrency?

Each project will adjust its structure with the growth of users and data to face future problems , and we are no exception. After the official public beta of our platform on January 5, it has aroused enthusiastic responses from many viewers. Only 4 days, registration The users will break 10,000. What followed was that the platform started to become stuck, so we started our troubleshooting and optimization. Let's talk to you about how we dealt with it.

Nginx

The core of a website is divided into several parts: front-end, back-end services, database, and server. Our first project was a jar package. One tomcat cannot support much concurrency. The maximum number of requests for Tomcat's default configuration is 150, which means that it supports 150 concurrency at the same time. Of course, you can also increase it. But every time we broadcast live, the concurrency will increase sharply, so we can only start to build clusters.

After the cluster was built, Nginx was introduced as a reverse proxy, and the load balancing was also solved. We weighted the performance of different servers. Sure enough, Nginx was added. After the load, the website access was much faster. However, the problem of session sharing is ushered in. We put the user's session information into redis, and the session sharing is done. After finishing the access layer, we found that our Jianghu module was still very slow.

Slow SQL

We started investigating the logs and found that some SQL processing took about 1.5 seconds, which was unbearable. The fundamental problem is that we have made a query with associated tables, and there are more associated tables, so we started to optimize the database structure and added a lot of redundant fields. At the back of the home page, we only need to query one table. From the speed to the present, it has been opened almost in seconds. . Classification We range from database query optimization to the use of static data management, because it hardly changes. At the same time, we also dealt with the sql of the message prompt and the sql of the personal homepage, so the response speed of the entire website has been greatly improved.

Master-slave replication, read-write separation

After solving the problem of the access layer, we found that the pressure bottleneck of the project was transferred to the database. At the beginning, we were still a single database, but the enthusiasm of users far exceeded our imagination. Reading and writing are all in the same database, and the performance is not enough. So we bought another server and started to be the master-slave. The master-slave of MySQL is relatively simple. Just a few commands are built. Then we use sharding jdbc to do read-write separation. After writing, the overall performance of the website has improved. So we released a version to ensure that the online operation does not freeze.

Trust and responsibility

For one week, we went to bed at two or three in the morning, constantly optimizing user suggestions to make the platform more and more stable and complete, but the hard work is worthwhile. There are more and more users, and while we have many years of membership, We have also welcomed our first lifetime membership. This is trust and responsibility. I can't live up to everyone's trust, do more meaningful things, do more pure communities, do more open source components and better tutorials to help everyone, this is the mission of our team, and also the mission of learning companions.

No matter how many bugs we encounter, just like Fei Ge said, we will be over if we eliminate them! There is no problem that cannot be solved, this is the confidence that belongs to our technical people!

Invite to settle in

If you usually have a hobby of writing articles, or already have a lot of notes, you are welcome to move your articles to our kuangstudy platform and provide valuable opinions. Maybe we are not the best right now, but we will try to change Become the best!

Accompanied by learning, accompanied by life!

After seeing this, you might as well support us with a like!

Guess you like

Origin blog.csdn.net/qq_33369905/article/details/112750553