Apache-nginx comparison and VPS Performance Optimization Summary

Source: Internet
Author: User
Tags vps

by Xtblock/abamon

My personal blog station: www.zy2zy.com

Reprint Please specify source: Http://www.zy2zy.com/apache-nginx comparison and VPS Performance Optimization Summary/


Objective

Apache and Nginx are open source, cross-platform, free HTTP server. Apache has been the most popular server since 1996, and by 2009, the Apache site has reached 100 million. The goal of Nginx design is to become an efficient server for reverse proxy and static content. In the case of the same traffic, Nginx takes up less memory and recommends the use of the website running on the VPS.


Difference

1, from the architecture, Apache is a process-based network server, each HTTP request will have a corresponding thread to handle it, each thread produces a small cost. Nginx is an event-based lightweight Web server that requires only a handful of threads to handle a large number of request, and the overhead required to process each request is very small.


2, from the functional level, Apache is undoubtedly the most comprehensive, but if only need to do a small blog station, Apache more out of those functions equivalent to none. Apache supports all features supported by Nginx, and the list is as follows:

Static file SSL/TLS virtual host reverse proxy load balancer compression access control URL redirection custom log SSI (Server-side includes) flvfastcgi
In addition, Apache also has Ruian features:

Management Console. htaccess

3, from the performance point of view, Apache is blocked, and Nginx is asynchronous. In dealing with static files, because Nginx does not need to open new threads for new request processing, the memory consumption is significantly better than Apache.

Nginx and Apache Summary

Apache

Advantages:

1, strong compatibility;

2, can choose the module rich;

3, the processing of dynamic requests more efficient;

Nginx

Advantages:

1, lightweight, in the case of processing the same request, Nginx occupies much less memory than Apache;

2, high concurrency, because Nginx is asynchronous non-blocking, so in the high concurrency of Nginx can also keep low resource consumption and high performance;

3, highly modular design, writing and adding modules relatively simple;

Disadvantages:

1, processing the dynamic request (that needs the server to perform certain operations to respond to the request), Nginx is inferior to Apache;


Experience and feel

Since the server was set up, it was found that the more memory was used, the more it was until the database was down and the server had to be restarted. While the time to wait for each visit is particularly long, viewing the network latency is only 500ms, which means that the server is processing the request too long. Based on the research and other findings, I've done two things to improve the performance of my VPS:

1, the page static. Because this is a personal blog post, there is nothing that needs to be computed on the server to be returned to the user, so a static web page avoids unnecessary computations. The time to access the site after the adjustment has been shortened, but still unsatisfactory.

2, adjust the structure. The schema was changed from LAPM (Linux+apache+php+mysql) to LNPM (Linux+nginx+php+mysql). After adjusting the structure, the waiting time of accessing the homepage is reduced, but still unsatisfactory, but in the first page to jump to other pages is basically within 1 seconds, you can say that the switch between the page experience has a qualitative improvement.


At last

For the low-demand users of our self-built blogging site, I think Chris Lea has summed up the image: Apache is a Microsoft Word with a lot of choices, but you only use 6 of them. And Nginx only provides these 6 functions, and nginx in which 5 functions faster than Apache 50 times times. (50 times times it feels a little exaggerated, but it's a lot faster)


Reference Catalogue

[1]. "Apache vs Nginx" Http://www.wikivs.com/wiki/Apache_vs_nginx

[2]. "Apache vs Lighttpd vs Nginx contrast" http://www.cnblogs.com/oubo/archive/2012/05/21/2511726.html

[3]. What are the pros and cons of Nginx and Apache http://www.zhihu.com/question/19571087

[4]. Comparison and merit of Apache, Nnginx, lighttpd http://sjolzy.cn/ Web-server-apache-nnginx-lighttpd-comparison-and-selection-of-the-best.html

Apache-nginx comparison and VPS Performance Optimization Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.