{"id":954,"date":"2022-09-09T17:02:28","date_gmt":"2022-09-09T17:02:28","guid":{"rendered":"https:\/\/sunucucozumleri.com\/?p=954"},"modified":"2025-01-06T17:15:04","modified_gmt":"2025-01-06T14:15:04","slug":"nginx-optimizasyonu-yaparak-site-hizini-artirmak","status":"publish","type":"post","link":"https:\/\/sunucucozumleri.com\/blog\/nginx-optimizasyonu-yaparak-site-hizini-artirmak\/","title":{"rendered":"Nginx Optimizasyonu Yaparak Site H\u0131z\u0131n\u0131 Art\u0131rmak"},"content":{"rendered":"<p>Merhabalar,<br \/>\nBug\u00fcn siz de\u011ferli ziyaret\u00e7ilerimize\u00a0<strong>Nginx optimizasyonu<\/strong>\u00a0konusunda ipu\u00e7lar\u0131 vermeye \u00e7al\u0131\u015faca\u011f\u0131z.<\/p>\n<p>\u00d6ncelikle\u00a0<strong>Nginx Nedir<\/strong>\u00a0?<\/p>\n<p><strong>Nginx<\/strong>\u00a0aslen mail.ru isimli rus mail sunucusu sitesi i\u00e7in Rus yaz\u0131l\u0131m m\u00fchendisi Igor Sysoev taraf\u0131ndan geli\u015ftirilen hafif, stabil, h\u0131zl\u0131 bir mail istemcisi olarak kodlanan daha sonralar\u0131 geli\u015ftirilerek t\u00fcm sunucular i\u00e7in uygun hale getirilen bir\u00a0web\u00a0sunucusudur. \u00a0Apacheden % 400 daha performansl\u0131 oldu\u011fu testler ile kesindir. Nginx \u00f6zellikle y\u00fcksek trafikli ve yo\u011fun web siteleri i\u00e7in birebirdir. Single Thread yan\u0131t yap\u0131s\u0131yla sayfay\u0131 tek hamlede y\u00fckleyip sayfa a\u00e7\u0131lma h\u0131zlar\u0131nda g\u00f6zle g\u00f6r\u00fcl\u00fcr bir art\u0131\u015f sa\u011flar. Ayr\u0131ca nginx apache ve litespeed ile kar\u015f\u0131la\u015ft\u0131r\u0131ld\u0131\u011f\u0131nda \u00e7ok daha az\u00a0cpu\u00a0kullan\u0131r. Buda\u00a0<a href=\"https:\/\/sunucucozumleri.com\/blog\/sunucu\/sanal-sunucu\/\">vps<\/a>, vds gibi\u00a0<strong>sanal <a href=\"https:\/\/sunucucozumleri.com\/blog\/frontpage\/\">sunucu<\/a><\/strong>lar i\u00e7in Nginx&#8217;in ideal oldu\u011fu anlam\u0131na gelir.<\/p>\n<p><strong>Temel HTTP \u00f6zellikleri<\/strong><\/p>\n<p><strong>*\u00a0<\/strong>Statik ve\u00a0index\u00a0dosyalar\u0131n\u0131n sunumu, otomatik indeksleme; a\u00e7\u0131k dosya a\u00e7\u0131klay\u0131c\u0131 \u00f6nbellek;<br \/>\n<strong>*\u00a0<\/strong>\u00d6nbellek ile h\u0131zland\u0131r\u0131lm\u0131\u015f reverse proxying; basit <a href=\"https:\/\/sunucucozumleri.com\/blog\/yuk-dengeleme-nedir\/\">y\u00fck dengeleme<\/a> ve hata tolerans\u0131;<br \/>\n<strong>*\u00a0<\/strong>Uzak FastCgi sunucular\u0131n\u0131n \u00f6nbelleklenmesi ile h\u0131zland\u0131r\u0131lm\u0131\u015f destek; basit y\u00fck dengeleme ve hata tolerans\u0131;<br \/>\n<strong>*<\/strong>\u00a0Mod\u00fcler yap\u0131. Gzip,\u00a0byte\u00a0aral\u0131klar\u0131, y\u0131\u011f\u0131n cevaplar (chunked responses), XSLT, SSI,\u00a0imaj\u00a0boyutland\u0131rma gibi filtreler. FastCGI veya proksilenmi\u015f sunucular ile tek bir sayfada \u00e7oklu SSI i\u00e7ermelerinin paralel i\u015flenmesi.<br \/>\n<strong>*<\/strong>\u00a0SSL\u00a0ve TLS SNI deste\u011fi.<\/p>\n<p>Nginx Optimizasyonuna Giri\u015f Yapal\u0131m<\/p>\n<p>*\u00a0Worker_process ve worker_connection ayarlar\u0131<br \/>\nKonsoldan a\u015fa\u011f\u0131daki komutu \u00e7al\u0131\u015ft\u0131r\u0131yoruz<\/p>\n<p>&nbsp;<\/p>\n<pre>grep processor \/proc\/cpuinfo | wc -l\r\n\r\n<\/pre>\n<pre>\u00f6rnek \u00e7\u0131kt\u0131 a\u015fa\u011f\u0131daki gibi olacakt\u0131r\r\n$ grep processor \/proc\/cpuinfo | wc -l\r\n8<\/pre>\n<p>\u015eimdi nginx.conf dosyas\u0131nda<\/p>\n<pre>worker_processes  \u00c7ekirdek Say\u0131s\u0131; olarak ayarlayal\u0131m\r\n\r\n<\/pre>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Makale \u0130\u00e7eri\u011fi<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"\u0130\u00e7indekiler Tablosunu A\u00e7\/Kapat\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/sunucucozumleri.com\/blog\/nginx-optimizasyonu-yaparak-site-hizini-artirmak\/#worker_connections_ayarlari_icin\" >worker_connections ayarlar\u0131 i\u00e7in<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/sunucucozumleri.com\/blog\/nginx-optimizasyonu-yaparak-site-hizini-artirmak\/#Tweaking_Buffers\" >Tweaking Buffers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/sunucucozumleri.com\/blog\/nginx-optimizasyonu-yaparak-site-hizini-artirmak\/#Sendfile_tcp_nodelay_ve_tcp_nopush_ayarlari\" >Sendfile, tcp_nodelay ve tcp_nopush ayarlar\u0131<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/sunucucozumleri.com\/blog\/nginx-optimizasyonu-yaparak-site-hizini-artirmak\/#open_file_cache_ayarlari\" >open_file cache ayarlar\u0131<\/a><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"worker_connections_ayarlari_icin\"><\/span>worker_connections ayarlar\u0131 i\u00e7in<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre>max_clients = worker_processes * worker_connections \r\n\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Tweaking_Buffers\"><\/span>Tweaking Buffers<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre>client_body_buffer_size 10K;\r\nclient_header_buffer_size 1k;\r\nclient_max_body_size 8m;\r\nlarge_client_header_buffers 2 1k;\r\n\r\n<\/pre>\n<p><code>client_body_buffer_size<\/code>\u00a0If the request body size is more than the buffer size, then the entire (or partial) request body is written into a temporary file.<\/p>\n<p><code>client_header_buffer_size<\/code>\u00a0For the overwhelming majority of requests it is completely sufficient with a buffer size of 1K.<\/p>\n<p><code>client_max_body_size<\/code>\u00a0Specifies the maximum accepted body size of a client request, as indicated by the request header Content-Length.<\/p>\n<p><code>large_client_header_buffers<\/code>\u00a0assigns the maximum number and size of buffers for large headers to read from client request.<\/p>\n<p>Timeout S\u00fcrelerini ayarlamak<\/p>\n<pre>client_body_timeout 12;\r\nclient_header_timeout 12;\r\nkeepalive_timeout 15;\r\nsend_timeout 10;\r\n\r\n\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Sendfile_tcp_nodelay_ve_tcp_nopush_ayarlari\"><\/span>Sendfile, tcp_nodelay ve tcp_nopush ayarlar\u0131<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre>sendfile on;\r\ntcp_nopush on;\r\ntcp_nodelay on;\r\n\r\nGzip S\u0131k\u0131\u015ft\u0131rma Ayarlar\u0131\r\n\r\n<\/pre>\n<pre>gzip on;\r\ngzip_min_length  1100;\r\ngzip_buffers  4 32k;\r\ngzip_types    text\/plain application\/x-javascript text\/xml text\/css\r\n\r\n\r\n<\/pre>\n<pre>location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {\r\nexpires 365d;\r\n}\r\n\r\nLog dosyalar\u0131n\u0131 ayarlamak\r\n\r\n<\/pre>\n<pre>access_log off;<\/pre>\n<pre>error_log logs\/error.log crit;\r\n\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"open_file_cache_ayarlari\"><\/span>open_file cache ayarlar\u0131<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre>open_file_cache max=5000 inactive=20s;\r\nopen_file_cache_valid 30s;\r\nopen_file_cache_min_uses 2;\r\nopen_file_cache_errors on;\r\n\r\n<\/pre>\n<pre>service nginx <a href=\"https:\/\/sunucucozumleri.com\/blog\/reboot-ve-restart-arasindaki-farklar-nedir\/\">restart<\/a><\/pre>\n<p>komutu ile nginx servisini yeniden ba\u015flat\u0131yoruz.<\/p>\n<p>\u0130yi \u00c7al\u0131\u015fmalar ve bol hitli g\u00fcnler dileriz.<\/p>\n<p>\u0130lginizi \u00c7ekebilecek Di\u011fer Makalalerimiz;<\/p>\n<p>1-\u00a0<a title=\"Sunucu Optimizasyonu\" href=\"https:\/\/sunucucozumleri.com\/blog\/sunucu-optimizasyonu-nedir-sunucu-optimizasyonu-nasil-yapilir\/\" target=\"_blank\" rel=\"noopener\">Sunucu Optimizasyonu<\/a><br \/>\n2-\u00a0<a title=\"Taray\u0131c\u0131 \u00f6nbellekleme \u00f6zelli\u011finden yararlan\u0131n - PageSpeed\" href=\"https:\/\/sunucucozumleri.com\/blog\/tarayici-onbellekleme-ozelliginden-yararlanin-pagespeed\/\" target=\"_blank\" rel=\"noopener\">Taray\u0131c\u0131 \u00f6nbellekleme \u00f6zelli\u011finden yararlan\u0131n &#8211; PageSpeed<\/a><br \/>\n3-\u00a0<a title=\"Wordpress Optimizasyonu\" href=\"https:\/\/sunucucozumleri.com\/blog\/17-adimda-wordpress-hizlandirma-ve-wordpress-optimizasyonu\/\" target=\"_blank\" rel=\"noopener\">WordPress Optimizasyonu<\/a><\/p>\n<p>Bol trafikler dileriz.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Merhabalar, Bug\u00fcn siz de\u011ferli ziyaret\u00e7ilerimize\u00a0Nginx optimizasyonu\u00a0konusunda ipu\u00e7lar\u0131 vermeye \u00e7al\u0131\u015faca\u011f\u0131z. \u00d6ncelikle\u00a0Nginx Nedir\u00a0? Nginx\u00a0aslen mail.ru isimli rus mail sunucusu sitesi i\u00e7in Rus yaz\u0131l\u0131m m\u00fchendisi Igor Sysoev taraf\u0131ndan geli\u015ftirilen hafif, stabil, h\u0131zl\u0131 bir mail istemcisi olarak kodlanan daha sonralar\u0131 geli\u015ftirilerek t\u00fcm sunucular i\u00e7in uygun hale getirilen bir\u00a0web\u00a0sunucusudur. \u00a0Apacheden % 400 daha performansl\u0131 oldu\u011fu testler ile kesindir. Nginx \u00f6zellikle &hellip;<\/p>\n","protected":false},"author":1,"featured_media":1456,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-954","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"acf":[],"_links":{"self":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts\/954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/comments?post=954"}],"version-history":[{"count":0,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts\/954\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/media\/1456"}],"wp:attachment":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/media?parent=954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/categories?post=954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/tags?post=954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}