Oct 7, 2015
Making Servers Fast AND Powerful
Written by Katie Gomez
I read a lot about how other people create their servers. Sometimes people ask what makes our servers so fast and so powerful. I love our technology, but I don’t always have the words to describe it. So I read what other people have written.
That paper referenced another. In https://web.stanford.edu/~ouster/cgi-bin/papers/threads.pdf the creator of TCL discussed why a single threaded application is usually better than a multi-threaded program. He discussed the tools required write code this way. The interesting part of this second article is that it was written over 20 years ago! The point is that only a few of us were doing this 20 years ago, but now it’s much more common.
Of course a lot has changed in 20 years. One change is particularly relevant. When that paper was written, most computers had only one one CPU. I just ordered a new computer with 16 real cores and 16 more if you count HyperThreading. And it wasn’t that expensive! One of the big problems of our day is how to make efficient use of all of these CPUs.
At Trade-Ideas we actually do both of these things. We have a front end like Node.js, or the TCL solution. We often use just one thread (or a small number of threads) to talk with the users, and we use the same tricks described above. We do this to keep things simple, so we can add new code when we need to. But we also have real work to do. (The first paper above was describing two web servers. They spend most of their time copying data from one place to another, not actually processing data. That’s what those tools are good at.) So we manage a number of worker threads in a very efficient way. And it’s all in one process. The front end can send a pointer to one or more other threads to do the work. You don’t have to copy any data from one application or one machine to the next.
We’ve developed a lot of our own tools to make this easier. We don’t have to start from scratch each time. Wether we’re in script or C++ we can quickly grab one of our proprietary libraries whenever we need to create a new server. We only have to write code for the new features. Our libraries take care of the details described above. They are our libraries, so we treat them with care. We are constantly smoothing out any rough spots, so they are easy to use.
It’s not about C++ vs scripting. It’s not about one thread vs many. It’s about picking the right tool at the right time. It’s about making all the pieces work together, when you make different decisions in different parts of your project. That is the magic at Trade-Ideas.