3 ms·
I've seen a lot of compromises around REST because of http 1.1 overhead. A great example of this happens when someone wants to query for a list of resources.
by cogman10 6y ago
I've seen a lot of compromises around REST because of http 1.1 overhead.
A great example of this happens when someone wants to query for a list of resources.
The rest way for this would be to do requests like this
get /foo/1
get /foo/2
get /foo/3
However, unless you spin up a bunch of parallel connections (wasting a bunch of resources both in the servers and the client), you are going to experience performance issues.
The compromise is to create endpoints that look like this
post /foo [1,2,3]
That saves the connection problem but creates a bunch of new issues. The client can send arbitrary request sizes to single servers (making LBing more difficult). It's not idiomatic, which means things like Http caching simply can't be used (or at least are less effective). A lot of http clients will do auto-retry but only for idempotent verbs, that's gone, you now need to implement all that stuff yourself.
http2 fixes all that. Making parallel requests for n datapoints isn't nearly as big an issue. Those requests can be fanned out to a bunch of servers and those servers can be in charge of figuring how how much batching thing should be doing before reaching out to the DB. Making it impossible for a single client to really tank the system.
Certainly you can work around this, usually by having the service farm out work over a message bus so you don't run into the problem of a single server going down due to a big request. However, the reason those message buses work and are fast is precisely because they are similar to Http2.
All of these have major consequences for backend services. If I have a fleet of apps talking to another fleet of apps, then it matters, a LOT, if each of those apps are creating 20 TCP connections to the other fleet. Get the wrong kind of load storm and your backend will topple over.
Now, is this super scientific? No. Rather it's based on what I've seen in the field.
Http2 has a ton of benefits when doing a lot of small message communication.