{"id":729,"date":"2022-04-18T06:10:49","date_gmt":"2022-04-18T00:40:49","guid":{"rendered":"http:\/\/blog.wpoven.com\/?p=729"},"modified":"2022-04-18T06:10:49","modified_gmt":"2022-04-18T00:40:49","slug":"nginx-vs-apache-which-is-better-for-your-wordpress-site","status":"publish","type":"post","link":"https:\/\/www.wpoven.com\/blog\/nginx-vs-apache-which-is-better-for-your-wordpress-site\/","title":{"rendered":"Nginx vs. Apache, which is better for your WordPress site"},"content":{"rendered":"<h2 style=\"text-align: center;\"><\/h2>\n<p><a href=\"https:\/\/www.wpoven.com\/blog\/wp-content\/uploads\/2014\/09\/apachevsnginx.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-772\" src=\"https:\/\/www.wpoven.com\/blog\/wp-content\/uploads\/2014\/09\/apachevsnginx-1024x515.png\" alt=\"apachevsnginx\" title=\"\"><\/a><\/p>\n\n<h2 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><em><strong>What is Nginx and Apache<\/strong><\/em><\/span><\/h2>\n<p>&nbsp;<\/p>\n<p>Nginx (Pronounced Engine-x) and Apache, both are open source web servers.<\/p>\n<p>The Apache web servers are the oldest ones around. They have been in use since 1995, whereas nginx came some where around 2002. Both the products are open-source and free but if you need support for nginx you will need to buy Nginx Plus version. Nginx was written primarily to address the <a href=\"http:\/\/www.kegel.com\/c10k.html\" target=\"_blank\" rel=\"noopener\">C10K problem<\/a>\u00a0and some performance and scalability issues associated with Apache.<\/p>\n<p><!--more--><\/p>\n<h2 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><em><strong>How They Work<\/strong><\/em><\/span><\/h2>\n<p>&nbsp;<\/p>\n<h3><span style=\"text-decoration: underline;\"><em>Apache<\/em><\/span><\/h3>\n<p>\u0097Apache \u00a0handles HTTP Requests sent to it.\u00a0It creates processes and threads to handle additional connections. The administrator can configure the server to control the maximum number of allowable processes. This configuration varies depending on the available memory on the machine. Too many processes exhaust memory and can cause the machine to swap memory to disk, thus severely degrading performance. Plus, when the limit of processes is reached, Apache refuses additional connections.\u00a0Apache is comprised of Two main building Blocks with the Latter being comprised of many other little building blocks. The Building Blocks are the Apache Core and then the Apache Modules that in a sense extend the Apache core.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-736\" src=\"https:\/\/www.wpoven.com\/blog\/wp-content\/uploads\/2014\/09\/02kew01.gif\" alt=\"02kew01\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3 class=\"lang:default decode:true\" style=\"text-align: center;\"><em>Apache is like Microsoft Word, it has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache.<\/em><\/h3>\n<h4 class=\"lang:default decode:true\" style=\"text-align: center;\">\u2014\u00a0<strong>Chris Lea on nginx and WordPress<\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3><span style=\"text-decoration: underline;\"><em>Nginx<\/em><\/span><\/h3>\n<p>Nginx works differently from Apache, specially how it handles threads. It uses\u00a0<strong>Event-driven<\/strong>, <strong>asynchronous<\/strong>, non-blocking and <strong>single threaded<\/strong> architecture.<\/p>\n<ul>\n<li><span style=\"line-height: 13px;\"><strong>Event Driven :\u00a0<\/strong>The starting and completion of events are marked by notifications, therefore the resources can be used by the other process until a process start or completion notification is received.<br \/>\n<\/span><\/li>\n<li><strong>Asynchronous :\u00a0<\/strong>Threads can be run concurrently, thus they do not block each other.<\/li>\n<li><strong>Single Threaded :\u00a0<\/strong> As the resources are not blocked therefore, multiple clients can be handled by a single worker process.<\/li>\n<\/ul>\n<p>The following diagram represents the Nginx architecture :<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.wpoven.com\/blog\/wp-content\/uploads\/2014\/09\/nginx-architecture.png\"><img decoding=\"async\" class=\"aligncenter wp-image-741\" src=\"https:\/\/www.wpoven.com\/blog\/wp-content\/uploads\/2014\/09\/nginx-architecture.png\" alt=\"nginx-architecture\" width=\"427\" height=\"278\" title=\"\"><\/a><\/p>\n<h2 style=\"text-align: left;\"><\/h2>\n<h2 style=\"text-align: left;\"><\/h2>\n<h2 style=\"text-align: left;\"><\/h2>\n<h2 style=\"text-align: left;\"><\/h2>\n<p>&nbsp;<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<h2 style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><em><strong>Pros and Cons<\/strong><\/em><\/span><\/h2>\n<h3><span style=\"text-decoration: underline;\">Apache<\/span><\/h3>\n<p><strong>\u00a0<em>Pros<\/em> :<\/strong><\/p>\n<ul>\n<li><strong>Large number of Modules:\u00a0<\/strong>Apache been available since many years and \u00a0has a larger community base, therefore has lots of Open-source modules written to expand it&#8217;s functionality.<\/li>\n<li><strong>Open Source :\u00a0<\/strong> Everything \u00a0relating to Apache is free, be it there modules or there support.<\/li>\n<li><strong>Large number of Users :\u00a0<\/strong>Nearly 46% of all websites run on Apache.<\/li>\n<\/ul>\n<p><strong><em>Cons<\/em> :<\/strong><\/p>\n<ul>\n<li><span style=\"line-height: 13px;\"><strong>Less Secure<\/strong> than nginx.<\/span><\/li>\n<li>Requires a <strong>heavy server configuration<\/strong> to handle high traffic websites. Since it spawns new process threads for each request, Apache requires a high memory footprint.<\/li>\n<\/ul>\n<h5><span style=\"line-height: 13px;\">\u00a0<\/span><\/h5>\n<h3><span style=\"text-decoration: underline;\">Nginx<\/span><\/h3>\n<p><strong><em>Pros<\/em> :<\/strong><\/p>\n<ul>\n<li><span style=\"line-height: 13px;\"><strong>Fast<\/strong> : It does not create a new process for each new request, therefore it becomes very fast.<\/span><\/li>\n<li><strong>Lightweight<\/strong> : As Nginx comes only with the core features required by the server, it makes it lightweight in comparison to Apache and hence consumes less memory as well.<\/li>\n<li><strong>Easy Scalability:<\/strong>\u00a0Nginx is highly scalable, and it&#8217;s performance is not dependent on hardware.<\/li>\n<\/ul>\n<div>\n<p class=\"lang:default decode:true \" style=\"text-align: left;\"><strong><em>Cons<\/em>:<\/strong><\/p>\n<ul>\n<li><span style=\"line-height: 13px;\">Does not<strong> support Operating Systems<\/strong> like OpenVMS and IBMi.<\/span><\/li>\n<li><strong>Limited support:\u00a0<\/strong>The Nginx community is not as big as the Apache community and it is repetitively newer as compared to Apache, so the community is also smaller for now.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div>\n<h2 style=\"text-align: center;\">\u00a0<span style=\"text-decoration: underline;\"><em><strong>Conclusion\u00a0<\/strong><\/em><\/span><\/h2>\n<p>With the above advantages in mind, more and more people are moving towards Nginx. Even WordPress.com was shifted over to Nginx and they have thousands of servers, serving thousands of requests per second. Also Nginx has become the number 1 web server for the top 10,000 websites on the internet (<a href=\"http:\/\/nginx.com\/news\/nginx-becomes-number-one-web-server-top-10000-busiest-websites-world\/\" target=\"_blank\" rel=\"noopener\">Read more<\/a>).<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" class=\"aligncenter size-large wp-image-772\" src=\"https:\/\/www.wpoven.com\/blog\/wp-content\/uploads\/2014\/09\/apachevsnginx-1024x515.png\" alt=\"apachevsnginx\" title=\"\"\/><br \/>\nWhat is Nginx and Apache<br \/>\n&nbsp;<br \/>\nNginx (Pronounced Engine-x) and Apache, both are open source web servers.<br \/>\nThe Apache web servers are the oldest ones around. They have been in use since 1995, whereas nginx came some where around 2002. Both the products are open-source and free but if you need support for nginx you will need to buy Nginx Plus version. Nginx was written primarily to address the C10K problem\u00a0and some performance and scalability issues associated with Apache. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.wpoven.com\/blog\/nginx-vs-apache-which-is-better-for-your-wordpress-site\/\" class=\"more-link\">Read More <i class=\"fa fa-angle-double-right\" aria-hidden=\"true\"><\/i><span class=\"screen-reader-text\"> &#8220;Nginx vs. Apache, which is better for your WordPress site&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ub_ctt_via":"","footnotes":""},"categories":[14,15,16],"acf":[],"featured_image_src":null,"author_info":{"display_name":"Vikrant Datta","author_link":"https:\/\/www.wpoven.com\/blog\/author\/vikrant\/"},"_links":{"self":[{"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/posts\/729"}],"collection":[{"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/comments?post=729"}],"version-history":[{"count":2,"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/posts\/729\/revisions"}],"predecessor-version":[{"id":7895,"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/posts\/729\/revisions\/7895"}],"wp:attachment":[{"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/media?parent=729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wpoven.com\/blog\/wp-json\/wp\/v2\/categories?post=729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}