Skip to content

Instantly share code, notes, and snippets.

upstream uwsgi {
ip_hash;
server 127.0.0.1:40000;
}
server {
listen 80;
server_name www.domain.com;
root /sites/mysite/;
access_log /sites/mysite/log/nginx/access.log;
git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT HEAD | xargs tar -rf mytarfile.tar

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The 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
@thegreenfield
thegreenfield / gist:6651849
Created September 21, 2013 16:04
Upgrading all packages with pip
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
@thegreenfield
thegreenfield / gist:6473862
Created September 7, 2013 08:21
Linux random noise sound
cat /dev/urandom | padsp tee /dev/audio > /dev/null
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@thegreenfield
thegreenfield / syncfork.bash
Created August 1, 2013 16:36
Auto Syncing a Forked Git Repository With the Parent
#!/usr/bin/env bash
# Author : Hemanth.HM
# License : MIT
# Some JSON parsing logic from http://l-o-n-g.livejournal.com/146422.html
# Get the current repo URL
url=$(git config --get remote.origin.url)
# Get the user and repo part from the URL
# Must be something like part=${url#*//*/}
// make sure we're using the right db; this is the same as "use aggdb;" in shell
db = db.getSiblingDB("aggdb");
// simple projection
var p1 = db.runCommand(
{ aggregate : "article", pipeline : [
{ $project : {
tags : 1,
pageViews : 1
}}