Nginx is suitable for which scenes apply

Share a picture

< p>

Initiate a web request, first go through ngnix, then to our application service (for example: tomcat), and then to visit our cache service (for example: redis) Or our database (for example: mysql). Finally, provide basic data services.

But there is a problem: our application service requires very high development efficiency, so its operating efficiency is very low. Its qps, or tps, or concurrency are all restricted, so we need to group many of these application services into a cluster.

Provide high availability to users. Once many application services form a cluster, we need ngnix to have a reverse proxy function that can pass dynamic requests to users. And many applications form a cluster, it will definitely bring two requirements:

1. We need dynamic expansion.

2. When some services go wrong, we need to do disaster recovery.

In this case, our reverse proxy must have a load balancing function. Secondly, in such a link, ngnix is ​​an edge node on the corporate intranet. As our network links grow, the delay experienced by users will increase.

So if we can cache some dynamic content that appears to be unchanged for all users or that does not change over a period of time in the ngnix section, ngnix will provide users with access directly. Then, in this case, the user delay will be reduced a lot.

Therefore, the reverse proxy has derived another function called caching. It can speed up our visit. And many times, we are accessing files like css or javascript or some small pictures, so there is no need for such static resources to be accessed by application services. It only needs to access the static resources placed on the system through local files and directly provided by ngnix. This is ngnix static resource.

So, the third application scenario is due to the performance of the application service itself, but the database service is much better than the application service. Because the business scenario of database service is relatively simple, its concurrent performance and TPS are much higher than application services.

Leave a Comment

Your email address will not be published.