6 ms·
Developers are generally oblivious to network latency. It's not just a LAN vs WAN thing either, the LAN will bottleneck if you have to cross the wire 1000 times
by flukus 9y ago
Developers are generally oblivious to network latency. It's not just a LAN vs WAN thing either, the LAN will bottleneck if you have to cross the wire 1000 times to full fill a request. n+1 queries aren't necessarily slow because the database has to do disk reads, they're slow because they have to go back and forth across the LAN thousands of times. There are seriously a lot of places out there that think a 10 second wait to load a table with 20 items is perfectly normal.
A common anti-pattern I see in the c# world is a pointless service layer (in a separate process) combined with n+1 crud data lookups. All the service layer brings to the table is a lot of serialization (which can be relatively expensive) and a doubling of network latency.
What's even worse is the commonly implemented solution: caching. The database get's unfairly blamed and a caching layer is added, of course this just adds another layer of network latency, does little for best case performance (data in cache) and worsens the worst case performance. Rant over.
Obligatory latency numbers every programmer should know: https://people.eecs.berkeley.edu/~rcs/research/interactive_latency.html https://people.eecs.berkeley.edu/~rcs/research/interactive_l...
- WatchDog 9y agoI too have seen many occurrences of the dreaded application level JOIN. Not to mention some of the craziness that happens when a "NoSQL" DB was chosen, when you really needed a relational database.
- flukus 9y agoI think these application level joins (great description, I'm stealing that in future) are responsible for half the instances NoSql databases (probably more) because relational ones weren't "scaleable" enough.
- hinkley 9y ago> and a doubling of network latency. Worse than that. Middleman services are almost never streaming. So they have to read the entire response, parse it, reformulate it and send it back out. Any IO and CPU bottlenecks are seen by the downstream server as additional latency.