14

I am currently working on an n-tier system and battling some database performance issues. One area we have been investigating is the latency between the database server and the application server. In our test environment the average ping times between the two boxes is in the region of 0.2ms however on the clients site its more in the region of 8.2 ms. Is that somthing we should be worried about?

For your average system what do you guys consider a resonable latency and how would you go about testing/measuring the latency?

4 Answers 4

14

Yes, network latency (measured by ping) can make a huge difference.

If your database response is .001ms then you will see a huge impact from going from a 0.2ms to 8ms ping. I've heard that database protocols are chatty, which if true means that they would be affected more by slow network latency versus HTTP.

And more than likely, if you are running 1 query, then adding 8ms to get the reply from the db is not going to matter. But if you are doing 10,000 queries which happens generally with bad code or non-optimized use of an ORM, then you will have wait an extra 80seconds for an 8ms ping, where for a 0.2ms ping, you would only wait 4 seconds.

As a matter of policy for myself, I never let client applications contact the database directly. I require that client applications always go through an application server (e.g. a REST web service). That way, if I accidentally have an "1+N" ORM issue, then it is not nearly as impactful. I would still try to fix the underlying problem...

2
  • Again resurrecting an old thread, but I too stumbled on this. I agree that because of the chattiness of database activity, monitoring database rtt latency is important. The tool my company provides (www.heimdalldata) has in addition to many other features an easy to use mechanism that will add a specified amount of latency to a query, so that the impact on the application can be measured. Additionally, it will help spot redundant queries, and through rules, allows configuring caching at a query or table level. The fast queries are the ones that never leave the application! Nov 1, 2016 at 18:27
  • I came across this as I was curious how slow a service we rely on at work is. The latency on that is about 50ms, it's crazy you're using 8ms as the slow example lol.
    – Peter
    Jul 28, 2021 at 12:37
12

In short : no !

What you should monitor is the global performance of your queries (ie transport to the DB + execution + transport back to your server)

What you could do is use a performance counter to monitor the time your queries usually take to execute. You'll probably see your results are over the millisecond area.

There's no such thing as "Reasonable latency". You should rather consider the "Reasonable latency for your project", which would vary a lot depending on what you're working on. People don't have the same expectation for a real-time trading platform and for a read only amateur website.

1
  • There is built-in functionality in SQL for that too. Don't set a filter of 1ms though or you won't see the ops that executed faster. Mar 3, 2011 at 19:10
6

On a linux based server you can test the effect of latency yourself by using the tc command.

For example this command will add 10ms delay to all packets going via eth0

tc qdisc add dev eth0 root netem delay 10ms

use this command to remove the delay

tc qdisc del dev eth0 root

More details available here: http://devresources.linux-foundation.org/shemminger/netem/example.html

All applications will differ, but I have definitely seen situations where 10ms latency has had a significant impact on the performance of the system.

2

One of the head honchos at answers.com said according to their studies, 400 ms wait time for a web page load is about the time when they first start getting people canceling the page load and going elsewhere. My advice is to look at the whole process, from original client request to fulfillment and if you're doing well there, there's no need to optimize further. 8.2 ms vs 0.2 ms is exponentially larger in a mathematical sense, but from a human sense, no one can really perceive an 8.0 ms difference. It's why they have photo finishes in races ;)

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.