Nginx and Apache Web servers are the two most common open source in the world. Together, they account for more than 50% of the internet traffic. Both solutions are able to handle different workloads and work with other software to provide a complete web stack.
Although Apache and Nginx share many qualities, they should not be considered as fully interchangeable. Each highlight in its own way and it is important to understand the situations in which you may need to reevaluate your web server of choice. post freelance projects and design your site with freelance designer. This article will be devoted to a discussion on how each server piles in different areas.
Before deepening the differences between Apache and Nginx, briefly look at these two projects and their general characteristics.
The Apache HTTP server was designed by Robert McCool in 1995 and has been developed under the direction of the Apache Software Foundation since 1999. As the HTTP web server is the original sketch of the base and is by far the most popular software, it is often called simply “Apache”.
The Apache web server is the most popular server on the Internet since 1996. Due to this popularity, Apache has excellent documentation and built other supports software projects.
Apache is often chosen by administrators for its flexibility, power and widespread support. It is expandable through a dynamically loaded module system and can handle a large number of languages interpreted without connection to separate software. If you have apache knowledge, you can post freelance projects on freelancer site or get your Apache knowledge from freelance designer.
In 2002, Igor Sysoev started working on Nginx in response to the C10K problem, which was a challenge for web servers to start managing ten thousand concurrent connections as a requirement for the modern web. The initial public launch was made in 2004, meeting this goal, relying on asynchronous architecture and events.
Nginx has grown in popularity since its release because of its moderate use of features and its ability to switch easily on minimal hardware. Nginx is great at delivering static content quickly and is designed to stream dynamic applications to other software more suitable for those purposes.
Nginx is often chosen by the principals for the efficiency and responsiveness of their features under load. Advocates welcome Nginx’s emphasis on the key Web server and proxy features.
Connection Management Architecture
One big difference between Apache and Nginx is the way they handle connections and traffic. This is perhaps the most important difference in the way they respond to different traffic conditions.
Apache provides a variety of multi-processing modules (Apache calls these MMPs), which determines how customer requests are processed. Basically, it allows administrators to easily swap their connection management architecture. These are:
Mpm_prefork: This processing module generates a process with a single thread each to process the request. Each child can manage a single connection at a time. Since the number of applications is less than the number of processes, MPM is very fast. However, performance degrades quickly after the applications exceed the number of processes, so it is not a good choice in many scenarios. Each process has a significant impact on RAM consumption, so this MPM is difficult to size effectively. This may still be a good choice, although used in conjunction with other components that are not built with topics in mind. For example, PHP is not wired prey, so MPM is recommended as the only safe way to work with mod_php, the Apache module to process these files.
Mpm_worker: This module generates the processes that each lever of multiple segments can. Each of these topics can handle a single connection. Threads are much more efficient than a process, which means MPM is better than MPM prefork. Since there are more topics than processes, this also means that new connections can immediately take a free thread instead of waiting for a free process.
Mpm_event: This module is similar to the working module in most situations, but is optimized to manage keep-alive connections. When using the worker MPM, a connection contains a wire regardless of an application to be activated while the connection is kept alive. The MPM event manages connections by constantly placing dedicated side topics to handle active connections and transmission of active requests to other topics. This prevents the drive from being blocked by keep-alive applications, allowing faster execution. This was marked stable, with Apache 2.4 release.
As you can see, Apache provides a flexible architecture for choosing different connection and request management algorithms. The choices are mostly based on server changes and the growing need for competition as the Internet landscape has changed.
Nginx came on the scene after Apache, with more awareness about the competition issues facing the sites of scale. By leveraging this knowledge, Nginx is designed to use an asynchronous, non-blocking, and event management algorithm.
Nginx generates work processes, each of which can handle thousands of connections. Work processes achieve this by creating a fast looping mechanism that constantly checks and processes events. Decoupling real work from connections allows each worker to worry about a connection only when a new event has been triggered.
Each of the worker treated links is placed in the cycle of events where they exist with other links. In the circuit, events are processed asynchronously, thereby handling non-blocking tasks. When the connection is closed, it is removed from the circuit.
This connection allows Nginx rendering style to spread incredibly far with limited features. Because the server is simple and processes are not generated to handle each new connection usage, memory and CPU tend to remain relatively consistent even under high load.
What is NGINX?
Nginx is pronounced x-motor, and it’s just a server engine that can do several things. The definition Wikipedia is Nginx:
In my configuration, I have the Nginx configuration as a replacement for Apache (web server) and I replaced PHP PHP-fpm, but I always had the MySQL run.
I have a project that I have a math calculation that took about 30 seconds to calculate, without cache. I wanted to improve faster, and after a few days of hard coding, I had time to calculate up to 8 seconds. He was working on LAMP! (Apache and PHP 5.3.14)
If the rumors were true about Nginx, so I could calculate that calculation even faster – I had to try. The challenge was created – make the calculation fast again!
First, it had to be installed Nginx, which, at first, seemed to be a pain in the back, simply because the tutorials available presented some local settings and requirements, which I did not have! So after hours of searching, pure brute force and a few whiskeys later, I managed to get Nginx, MySQL and PHP-fpm installed and configured via Brew on my Mac 10.8.
Tests carried out included the following:
- Intel Core i7 Processor 2.3 GHz
- Memory 8 GB DDR3 1600 MHz
- OS X 10.8.2 software (12C2034)
- NGINX 1.27
- PHP 5.3.15
- MySQL 5.6.12
- Apache 2.2.22
- PHP 5.3.14
- MySQL 5.5.25
No chisés carry tests; 1 single application of 10 concurrent requests, 50 requests divided into 25 concurrent users.
For this test, I accessed the most complex calculation of my project, which handled 637 211 calculations involving a database, calculation and test lines using the Apache benchmarking tool.
The results were very mixed. Nginx has advanced, but my tests also showed some interesting stats too:
As you can see, Nginx offers a higher throughput compared to Apache, but also less waiting time between receiving the request and responding.
I also noticed that Nginx can handle more requests per second, and is able to increase as the load increases, but Apache remained relatively static on that front.
The incredible statistics for my limited machine, I’ll give you this, was the deposit fee to place, where 7 orders in 50 failed the top load test, while Nginx fed in advance.
Although it appears that Nginx peaked at the transfer rate of 10 concurrent users, it appeared that it had reached a bottleneck on the ramp up to 25 users; other tests can see where that bottleneck is affected, although it is a slight decrease while Apache remained unchanged over the Average transfer rate.
For some relationship figures:
As you can see, nginx wins every time, but what’s more important is that Apache actually achieved a withdrawal rate with 25 concurrent users, which by 25 users, 3-4 lose the connection.
Nginx can also manage the average traffic 40% higher than Apache in less than 300%. (Basically, it’s 4.2 times faster than Apache on average, these tests, and much more reliable!).
As you can see, Apache and Nginx are powerful, flexible, and capable. Deciding which server is best for you is largely based on an assessment of your needs and specific tests with templates you expect to see.
There are differences between these projects that have a very real impact on the gross performance, capacity and implementation time required for each solution is operational. However, this is usually the result of a series of commitments that should not be casually dismissed. In the end, there is no single Web server, but use the solution that best fits your goals.