Open Sourcing Our Go Libraries (2014)
tech.dropbox.com
tech.dropbox.com
Scaling problems in large systems are rarely solved at the micro level, i.e. you don't "scale" by simply gaining the ability to run more operations in a single thread. This is always the problem with "language X is more scalable than Y" debates. From my experience scale has little to do with language, everything to do with how you use it.
This post brings to mind another written by Alex Payne a few years back about scaling in the large vs. scaling in the small:
https://al3x.net/2010/07/27/node.html
The danger with making hand-wavy claims with very few technical details is that it perpetuates the notion that there are certain magic bullets out there that will magically make your system "scale" if you use them. In the past few years we've seen quite a few large companies in SV and SF make the switch to some shiny new language (Scala, anyone?) only to find several million dollars and many months later that they're still having conversations about how to make stuff scale. Only now they're talking about making it happen in a language that is fairly new to their organization and with which they have only a few real experts.
This switch (Python to Go) for this motivation (better concurrency support) seems reasonable to me, particularly since Python does not have a good concurrency story. (I love Python. But I would not choose it if I wanted high concurrency.)
Why ? Less resource-hungry code requires less resources and doesn't cause problems quite so quickly (tends to cause harder problems though). 8 years ago I switched the directory on a site that required >30 servers to run to tmpfs, and did some serious sql optimization in the php code. The month after that I turned down 20 of them (actual servers + caching and load balancing servers that weren't necessary anymore).
In this case, you're talking about Dropbox, which already has achieved the scale, in both the large and small senses, that require a deeper level of problem solving than simply switching languages would provide.
Even if I personally find Go an odd choice for this project (why not C++, which already has the library support they need, and much more?), their present-day successes demonstrate that they didn't expect a scalability panacea from Go, just a better runtime for a subset of their critical path code.
The OP says as much in the comments: "For us, one of the biggest latency wins comes from the fact that go can truly execute sql statements in parallel (whereas python's GIL serialized these parallelizable operations). In general, single-threaded go is at least 5x faster than pure python (without c-module)."
1) Regarding concurrency, Go really pushes you towards writing things in a scalable way with the goroutines and channels, while still giving you mutexes for when those are the best fit.
2) Regarding single-threaded performance, this does indeed start mattering once you un-bottleneck-yourself on the architecture and concurrency fronts. 250 boxes are cheaper than 500.
For us, one of the biggest latency wins comes from the fact that go can truly execute sql statements in parallel (whereas python's GIL serialized these parallelizable operations). In general, single-threaded go is at least 5x faster than pure python (without c-module).
That said, if you're running Go against n number of CPUs, then yes, the concurrency may in fact happen in parallel.
I'm not quite sure whether dropbox didn't or couldn't get gevent or a similar system to work - it's fairly straightforward.
I wonder if dropbox evaluated this option or just rejected python outright.
In Go, the API for goroutines and channels is superb, concise, and clear.
For me, the negative traits of Go outweigh the positive, but I really wish other languages would adapt some of its concurrency constructs as native language features.
https://github.com/dropbox/godropbox/commit/5ed34e410e1c9fe8...
It took me a while to "give up" and find fmt-massaged code natural.
Just glancing at dbox's caching package it looks like a much more general cache, with deletes and sets and all of that. So the two aren't really comparable.
2. Go allows true concurrency in many situations Python cannot (due to GIL etc); Go also supports lightweight threads that are multiplexed over actual OS threads.
3. Go makes it easier to control and reason about heap allocations.
4. Go is even easier than Python to integrate with C/ASM code.
It would be more accurate to say that Go allows parallelism in situations where Python (in the standard implementation, at least) does not. Calling parallelism (what the GIL prevents) "true concurrency" isn't particularly helpful.
This has more to do with the interpreter, of course, you can compete with PyPy.
Only specific, common, core services (storage etc.), are being written in golang; the "long tail" of application code on the backend is (and will remain) in Python.
- Dropbox infrastructure engineer
Since Dropbox has rewritten a chunk of systems in Go it suggests that Pyston isn't working out.
* Start with python * Find out it's a little horrible. * Hire Guido * Python still a little horrible. * Switch to Go
Much more along the lines of:
* Start with Python
* Have a great time and build successful apps with it
* Become global-scale infrastructure provider
* Hit problems that only occur at that scale and switch tools
The take-away is, you're almost certainly not going to end up at the size of Dropbox. If you're spending ages as a startup futzing around using bleeding-edge technology just because it's cool, you might well be wasting time – or at least prematurely optimising.
This is the perfect example – Dropbox has the engineering talent to write a set of libraries to implement basic features. Earlier-stage companies don't have that luxury.
I don't know about you but its hard to sell upper managers on complete rewrites of things when the end result is: no real change but it might/should/could run faster. Unless performance is a concern to be addressed the risk of changing technology stacks doesn't seem a great idea.
> HN post about any language > Snarky comment about any language > Language war
It's depressing that your comment has percolated to the top of the thread; it has nothing whatsoever to do with the story.
Well, praise for a language is telling people how it suits your needs, so...
>For clarification, Dropbox will continue to develop majority of its features in Python.
Besides that, they're migrating only some parts of the backend. They're not "switching". The rest is still Python.