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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
palash25@Lenovo-G50 ~/Dev/Projects/wc master ? \time --format "\n real %E\t user %U\t sys %S\t mem %K\t ssize %p" wc ../../small-file-* | |
48414 81402 556859 ../../small-file-1 | |
48414 81402 556859 ../../small-file-2 | |
48414 81402 556859 ../../small-file-3 | |
145242 244206 1670577 total | |
real 0:00.05 user 0.05 sys 0.00 mem 0 ssize 0 | |
palash25@Lenovo-G50 ~/Dev/Projects/wc master ? \time --format "\n real %E\t user %U\t sys %S\t mem %K\t ssize %p" ./target/release/wc ../../small-file-* | |
48414 81402 556859 ../../small-file-1 | |
48414 81402 556859 ../../small-file-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
palash25@Lenovo-G50 ~ sudo dpkg --configure -a ✔ 10131 12:06:01 | |
Setting up mysql-server-5.7 (5.7.27-0ubuntu0.16.04.1) ... | |
Checking if update is needed. | |
Checking server version. | |
Running queries to upgrade MySQL server. | |
Checking system database. | |
mysql.columns_priv OK | |
mysql.db OK | |
mysql.engine_cost OK | |
mysql.event OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node-01 | |
cluster.name: test | |
node.name: es-master-01 | |
node.master: true | |
node.ingest: false | |
node.data: true | |
http.enabled: false | |
path.data: data/master | |
discovery.zen.ping.unicast.hosts: ["localhost:9301", "localhost:9302"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3CN8lWy1taT/QvOR/eWNfpU7jV9vHNggS4389ZnTq1CaBWW5Z/ysmzaepsmJ5sADeuTGWCb8Gt/oeva7mypvwLsMXxkt/oomqdUAcKd41UtJHSYSmn75YiEYDsIRxE4J7ahQf5/gKOeM5IMT4LxDeItLl9tNpHze63ea6WznxMrPCy6mDb1x7wO5ziRQCjNOkZBS3FtVMlPU6bph+gCYPbAWv/da/9NxenUS+slPWt6BofWEd6pN1XJjHmf7O5jtSbJYKUGClJ35gOpO4osdUcZwXCzUMmLok1EXXwkio0bEZjn5ftmjWLvUJMMsnffk8na+Hsk+hoEeBfw3I32ln palash25@Lenovo-G50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id" : "uhxZabiBml", | |
"class" : "Response", | |
"type" : "baseline_response", | |
"keys" : "answers,responseId,formId,isActive", | |
"formId" : "nNpqEjFEj8", | |
"_p_organization" : "Organization$Ftu5QdMygg", | |
"isActive" : true, | |
"useMasterKey" : true, | |
"queryString" : "\"formId\":\"nNpqEjFEj8\",\"answers.questionId\":\"V9gv0mHlen\",\"answers.text\":\"Mathura\"", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an example of using elastic's BulkProcessor with Elasticsearch. | |
// | |
// See https://github.com/olivere/elastic and | |
// and https://github.com/olivere/elastic/wiki/BulkProcessor | |
// for more details. | |
/* | |
* This example illustrates a simple process that performs bulk processing | |
* with Elasticsearch using the BulkProcessor in elastic. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_source": ["_id"], | |
"from": 1, | |
"size": 10, | |
"query": { | |
"bool": { | |
"filter": [{ | |
"bool": { | |
"should": { | |
"bool": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"organizationId": "atlan", | |
"order": "asc", | |
"allFormsFLag": true, | |
"formId": "hHhcLKh9st1vFr8nDY4a", | |
"dateField": "_created_at", | |
"startDate": "2019-05-20", | |
"endDate": "2019-05-21", | |
"userId": [ | |
"gTOAbrbVUkPXgZYNXz2n" |