I have some early benchmark results for our work on a high performance NATS server in Go.
Quick Summary:
We can process ~2M msgs/sec through the system, and the ingress and egress are fairly well balanced.
The basics of the architecture are intelligent buffering and IO calls, fast hashing algorithms and subject distributor/routing, and a zero-allocation hand-written protocol parser.
In addition, I used quite a bit of inlining to avoid function overhead, no use of defer, and little to no object allocation within the fast path. I will share more details and the code at a future date.
This file contains hidden or 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
# vmc update is great for test and development, however it stops your old app and stages and starts the new one, | |
# resulting in dropped requests. | |
# If you want to update an application without dropping user requests, see below. | |
# NOTE: This change assumes your application can share services, etc with the new version. | |
# Assume my app is named foo | |
vmc push foo-v2 --url foov2.cloudfoundry.com |
This file contains hidden or 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
~/Development/vcap/apps/crash_foo> vmc push foo | |
Would you like to deploy from the current directory? [Yn]: | |
Application Deployed URL: 'foo.cloudfoundry.com'? | |
Detected a Sinatra Application, is this correct? [Yn]: | |
Memory Reservation [Default:128M] (64M, 128M, 256M, 512M, 1G or 2G) | |
Creating Application: OK | |
Would you like to bind any services to 'foo'? [yN]: | |
Uploading Application: | |
Checking for available resources: OK |
This file contains hidden or 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
~> telnet 127.0.0.1 4222 | |
Trying 127.0.0.1... | |
Connected to localhost. | |
Escape character is '^]'. | |
INFO {"server_id":"bae2f058b327a4b5ecff44407f","host":"0.0.0.0","port":4222,"version":"0.4.22","auth_required":false,"ssl_required":false,"max_payload":1048576} | |
sub foo 1 | |
+OK | |
pub foo 2 | |
hi | |
+OK |
This file contains hidden or 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
#!/usr/bin/tclsh8.5 | |
# | |
# Usage: unmerged branch1 branch2 | |
proc getlog branch { | |
lrange [split [exec git log $branch --oneline] "\n"] 0 100 | |
} | |
proc diff {title c1 c2} { | |
puts "\n$title" |
This file contains hidden or 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
{ | |
"http://api.cloudfoundry.qa.mozycloud.com/":"token-xxx", | |
"http://api.staging-cloudfoundry.com":"token-xxx", | |
"https://api.cloudfoundry.com":"token-xxx", | |
"http://api.derek.cloudfoundry.me":"token-xxx", | |
"http://api.vcloudlabs.com":"token-xxx", | |
"http://api.appcloud07.dev.mozycloud.com":"token-xxx", | |
"http://api.cloudfoundry.com":"token-xxx", | |
"http://cc.alpha.vmforce.com":"token-xxx", | |
"https://api.vcloudlabs.com":"token-xxx", |
This file contains hidden or 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
I have really come to enjoy working in Go. From time to time I expect that the team at Apcera will | |
need to dip back into C for some things, but I decided to try to push the envelope with Go on making | |
some faster HashMaps than Go's builtin map. I started with the hash algorithms. | |
These are some results from my MBA11" core i7.. The fastest Hash algorithms will not work on machines | |
without support for unaligned access, and I still need to do some cleaning up before we OSS, but so far so good. | |
I aslo need to implement the fastest one, FNV1A_Hash_Yorikke, from http://http://www.sanmayce.com/Fastest_Hash | |
I hack SetBytes(1) to get a rough idea of ops/sec, its not actually IO.. So 10 MB/s is 10 Million ops per sec. |
This file contains hidden or 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
I have done some more work on creating very fast hash algorithms in Go for small (3-8) and medium (16-32) size keys. Below are the current results. | |
NOTE: I used SetBytes(1) to give quick estimate of ops/sec | |
2012 MacbookAir 11" i7 2Ghz | |
================ | |
OSX - Mountain Lion | |
Go version go1.0.3 | |
================ |
This file contains hidden or 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
Impressed with the performance gains in go 1.1 on maps. I had to write my own for the original gnatsd. | |
HashMap is my own implementation. | |
go 1.0.3 | |
~/Development/go/src/github.com/apcera/gnatsd/hashmap> go test --bench="." | |
PASS | |
Benchmark_GoMap___GetSmallKey 50000000 53.1 ns/op 18.82 MB/s | |
Benchmark_HashMap_GetSmallKey 10000000 21.4 ns/op 46.69 MB/s | |
Benchmark_GoMap____GetMedKey 20000000 107 ns/op 9.27 MB/s | |
Benchmark_HashMap__GetMedKey 50000000 34.7 ns/op 28.78 MB/s |
This file contains hidden or 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
ubuntu vm on MBA 11" 2013 | |
ubuntu@apcera-raring-amd64:~/go/src/github.com/apcera/gnatsd/test$ go test --run="zzz" --bench="." | |
PASS | |
Benchmark___PubNo_Payload 10000000 209 ns/op 52.59 MB/s | |
Benchmark___Pub8b_Payload 10000000 293 ns/op 95.40 MB/s | |
Benchmark__Pub32b_Payload 5000000 433 ns/op 175.36 MB/s | |
Benchmark_Pub256B_Payload 1000000 1942 ns/op 270.28 MB/s | |
Benchmark___Pub1K_Payload 200000 8971 ns/op 229.84 MB/s |
OlderNewer