Just a few days in the past, I used to be questioning if utilizing Go could be value it when creating new net APIs.
I clearly knew that Go could be sooner than Ruby, however I wasn't positive
how a lot sooner. I additionally questioning concerning the quantity of labor required to
write get a full API applied.
I subsequently wrote the identical net API in Ruby (utilizing Rails) and in Go (at
first utilizing Revel after which rewriting it with no framework since Go's
std lib have the whole lot one may want).
The API spec was easy:
* extract an authorization token contained within the request header
* use the token to question a MySQL database
* reply by sending again the MySQL row in json format
* return 401 if the token is not worth
I did not attempt to optimize the Ruby code, nor the Go code. The thought wasn't
to get exact benchmark outcomes, the purpose was to get an thought of how
a lot sooner Go was in an actual life scenario. The opposite purpose was to
consider the quantity of labor wanted to write down net APIs in Go for somebody
who already is aware of the language.
On the finish of the day the API applied in Go is greater than 50x sooner than
the Ruby model. Attention-grabbing sufficient, writing the code and assessments for the
Go API was fairly near the Ruby expertise (extra on that later).
50X efficiency acquire, together with excessive concurrency help is perhaps a really
good argument to begin utilizing some Go when it is smart.
I documented my experiment on Google+, click on the next screenshot to learn extra.