Skip to content

Instantly share code, notes, and snippets.

View jetsanix's full-sized avatar
💭
💭💭💭

jet tsang zeon-git jetsanix

💭
💭💭💭
View GitHub Profile

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
@b123400
b123400 / three.php
Created August 13, 2012 21:00
3HK data usage getter
<?php
//There is no public API therefore this is not so reliable, use it at your own risk
function search_string($string , $regex , $index=1){
$pattern = "~".$regex."~";
preg_match($pattern, $string, $matches);
//var_dump($matches);
return $matches[$index];
}
function getDataUsageFromThreeAccount($mobileNo,$password){
$loginURL="http://www.three.com.hk/appCS2/verifyLogin.do?lang=eng";
$.fn.vectorMap('addMap', 'cn_merc_en',{"insets": [{"width": 560, "top": 0, "height": 470, "bbox": [{"y": -7092705.234177706, "x": 8197509.958779432}, {"y": -2058430.530198134, "x": 15010424.448806616}], "left": 0}],
"paths": {
aomen:{
name : "澳门特区",
path: "M413.032,414.183l-0.96,1.752c0,0,0.889,0.883,1.98,1.086s1.995-0.493,1.995-0.493L413.032,414.183z"},
hongkong:{
name : "香港特区",
path: "M417.745,409.005l3.394,0.773l3.453-2.558l1.666,4.582c0,0-5.521,2.673-3.691,1.785c1.828-0.884-4.641-0.355-4.641-0.355l-0.834-3.454L417.745,409.005z"},
taiwan:{
name : "台湾省",
@jetsanix
jetsanix / reset_app_store.sh
Created July 26, 2012 00:19
Reset the App Store on Os X Mountain Lion
#!/bin/sh
rm ~/Library/Preferences/com.apple.appstore.plist
rm -r ~/Library/Saved\ Application\ State/com.apple.appstore.savedState
rm -r ~/Library/Caches/com.apple.appstore
rm -r /private/var/folders/*/*/*/com.apple.appstore
@lhaagsma
lhaagsma / PoodleIptables
Created October 16, 2014 20:27
Drop successful SSLv3 connections using IPtables
# Matching 'SSL SERVER HELLO' packets using IPtables
# Using some connection tracking to make sure not
# to match randomly in the middle of some huge SSL
# session.
iptables --insert INPUT -p tcp --sport 443 \
-m connbytes --connbytes-mode bytes --connbytes-dir both --connbytes 0:500 \
-m state --state ESTABLISHED \
-m length --length 46:375 \
-m u32 --u32 "\
# Basic Strongswan ikev2 server setup
* paltform: atlantic.net ubuntu 14.04 x64
* the commands below are run with root account
## Strongswan
```
apt-get install strongswan
apt-get install iptables iptables-persistent
```
@ikbear
ikbear / NetScreen.md
Created December 5, 2012 17:17
NetScreen的往事

下面是陈首席陈临怀发表在微博上的 [NetScreen的往事],我在看的过程中将其拷贝出来,整理成文,方便想看的人一口气看完。微博见:http://weibo.com/huailinchen

[NetScreen的往事]下午要在厦门见邓锋。突然又想起了许多NetScreen的往事。我是一个能写代码的文艺青年。决定在weibo上,来写写过去,算作为逐渐老去的我们的一点纪念。。。

[NetScreen的往事(1)]2001年的9月11日的早晨。我大概7点左右被人叫醒。纽约遭遇攻击!“。在电视上我看着第2架飞机冲入Tower Building,恍惚做梦一般。。。 上午去公司。。。大家都很担心。知道NetScreen的创办人Feng和Yan也在纽约,处理公司上市的事情。大家都很担心他们。我们是兄弟。

[NetScreen的往事(2)]应该是中午的时候传来消息。他们已经跑到亚特兰大去了。在等待转机。。。大家都在等着他们的回来。记得是晚上7点左右,夏天的加州,依然天很亮。我和Shalang(现Juniper Beijing Director)在楼下抽烟。看见Feng和Yan下车了。。。我是个很感情化的人,冲上去拥抱了Feng。

[NetScreen的往事(3)]Yan是个比较严肃的人,而我的工作基本上是他和Yuming[Palo Alto创办人,今年上市,发大了]直接领导。他经常修理我。有点怕他。不敢和他拥抱。Feng很随和,喜欢开玩笑[含黄色段子]。大家都喜欢他。。。

@Machx
Machx / Blackboard.dvtcolortheme
Created February 4, 2011 20:02
Blackboard theme from TextMate for Xcode 4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>1 1 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
#!/bin/bash
if [[ "$#" < "2" || "$#" > "3" ]]; then
cat <<END
Glusterfs GFID resolver -- turns a GFID into a real file path
Usage: $0 <brick-path> <gfid> [-q]
<brick-path> : the path to your glusterfs brick (required)
@trunet
trunet / graphql-go-mongodb-example.go
Created June 18, 2018 13:28 — forked from aquiseb/graphql-go-mongodb-example.go
Minimal example of GraphQL Golang and MongoDB playing nicely together. Edit
// Embedded in this article https://medium.com/p/c98e491015b6
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"