Does anyone have experience with Go as REST application server? I'm in prototyping phase (in Python) of something that is basically going to be a big REST API frontend with a lot of application logic and a db backend. I'm worried about scale as if this thing is going to take off it needs to scale big and support tens of thousands (or more) of requests a second. From the article it sounds like Go would be a great choice, I found the "gorest" framework and it looks decent, but I'm wondering if anyone has experience in this area? Specifically the DB interfacing, JSON marshalling, and writing lots of classes with complex application logic parts.
It's a tiny rest api for generating promo codes to bypass in app purchase locks in an ios app. It uses gorilla/mux[1] for routing, mongodb with mgo[2], and is heroku-ready[3]. One file and 129 lines all told.
"I'm worried about scale as if this thing is going to take off it needs to scale big..."
Please don't say this.
If you are being paid by someone else, please check with them to ensure what their priorities are when things "scale big" bc often times you can bide yourself time if you have their requirements met while you scramble to make everything perfect on the backend.
If you are not being paid by someone else or this is a side project, then please do not try and solve this question now. Answers to questions of "scale" are so broad that you will drive yourself mad trying to find the "perfect" tool, when one doesn't exist. You don't scale a language or a framework, you scale application logic. Scaling to millions of requests is the best possible problem to have, but put yourself in a position to have that problem!
And asking basic questions of how to build something that can handle some amount of load in a language that you are not familiar with will FAR outweigh the perceived benefits of choosing that language/framework!
Building an API in Go feels -very- robust because of the strong typing and the strict compiler. After a while you'll discover the strength of interfaces and be pleasantly surprised. Combined with the performance boost, I can't think of a better language to write an API in.
FYI, you should replace DocsHandler with net/http's FileServer.
Reasons:
1) the implementation is not vulnerable to path traversal attacks (i.e. if url.Path == "/../../../../../etc/passwd").
2) It automatically handles index.html
3) It uses "/etc/mime.types" and other system files to automatically set mime types
4) It streams the file back instead of reading it all into memory.
> Does anyone have experience with Go as REST application server?
I'm developing my new startup (http://www.TurboHDR.com) in Go on App Engine and it's a very nice development environment.
As part of the process I recently developed a WebDAV package (which I'll open source soon) and it was quite straightforward thanks to Go's great XML package (http://golang.org/pkg/encoding/xml/) which automatically unmarshals XML into regular (possibly annotated) Go structures. The JSON package (http://golang.org/pkg/encoding/json/) can do the same. It's the most painless experience dealing with XML I've ever had.
Shameless plug: I wrote a package that exposes a CRUD JSON API on top of a backend interface ("Storage") which you implement yourself; so if your API fits the CRUD principle it could be worth to look at:
Try OpenResty - nginx + ngx_postgres/ngx_drizzle/ngx_hiredis/etc. for DB interfacing + ngx_rds_json for JSON marshalling + ngx_lua for complex application logic parts