Skip to content

Instantly share code, notes, and snippets.

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@xd547
xd547 / .vimrc
Created November 12, 2013 03:04
" encoding
set encoding=utf-8
set fileencoding=utf-8
" preference
syntax on
set ai
set shiftwidth=2
set tabstop=2
set softtabstop=2
@xd547
xd547 / rai
Created May 23, 2013 07:53
rolify after install
rails g rolify:role Role User
rake db:migrate
@xd547
xd547 / style.css
Created May 16, 2013 04:15
Remove default button style in ios and other browser .
input[type=button]{
-webkit-appearance: none;
outline: none;
-moz-appearance: none;
appearance: none;
}
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@xd547
xd547 / bootstrap_link_renderer.rb
Created September 15, 2012 08:14
will_paginate bootstrap
@xd547
xd547 / install-ruby-debug-ubuntu-ruby-1.9.3
Last active October 9, 2015 09:27 — forked from boriscy/install-ruby-debug-ubuntu-ruby-1.9.3
ruby-debug in ruby-1.9.3 and ubuntu
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
linecache19-0.5.13.gem
ruby_core_source-0.1.5.gem
ruby-debug19-0.11.6.gem
ruby-debug-base19-0.11.26.gem
#Then in your console
export RVM_SRC=/home/xd547/.rvm/src/ruby-1.9.3-p392
@xd547
xd547 / hot.py
Created November 15, 2014 08:12
from multiprocessing import Pool
def loop(x):
while True:
pass
Pool().map(loop, range(100))
@xd547
xd547 / index.js
Created August 21, 2014 08:59 — forked from edokeh/index.js
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
namespace sort
{
class Program