Skip to content

Instantly share code, notes, and snippets.

@philipz
Created July 3, 2015 07:41
Show Gist options
  • Save philipz/fadd2ddb92c4cf07fb10 to your computer and use it in GitHub Desktop.
Save philipz/fadd2ddb92c4cf07fb10 to your computer and use it in GitHub Desktop.

Revisions

  1. philipz created this gist Jul 3, 2015.
    29 changes: 29 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    [TCP LOAD BALANCING](https://www.nginx.com/resources/admin-guide/tcp-load-balancing/)
    ```
    user nginx;
    worker_processes 1;
    error_log /var/log/nginx/error.log warn;
    pid /var/run/nginx.pid;
    events {
    worker_connections 1024;
    }
    stream {
    upstream stream_backend {
    least_conn;
    server 172.17.0.34:3306 max_fails=2 fail_timeout=30s;
    #server backend2.example.com:12345 max_fails=2 fail_timeout=30s;
    #server backend3.example.com:12346 max_conns=3;
    }
    server {
    listen 3306;
    proxy_connect_timeout 1s;
    proxy_timeout 3s;
    proxy_pass stream_backend;
    }
    }
    ```