Measure response time between website visitor and DO regions

Background I am building a Ruby on Rails application that lets users deploy a server in the DO region of their choice.

Problem I’d like to show the latency between the user’s location and all the available DO regions so that the user can select the region with the fastest response time for them.

The latency can be easily calculated locally in development for each region with Net::Ping using the example code below:

  check =
  start_time =
  elapsed_time = ('%.6f' % ( - start_time))

However, in production, the originating IP is consistently the web host of my application, not the user’s IP address.

How can I measure the response time between a website visitor and a DO region?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Thanks for taking a look @bobbyiliev.

I was able to solve this problem by using JavaScript to ping a website hosted in each of DO’s regions. I used the speed test websites originally designed to help DO customers measure the upload/download speed from each region.

For example, the code below will ping a website hosted in each DO region and then print the response time latency in the console.

var region_data = [
  {"name":"New York","host":""}, 
  {"name":"San Francisco","host":""}, 

for (var i = 0; i < region_data.length; i++) {
  var xmlhttp = new XMLHttpRequest()
  var start_time =;'GET', region_data[i].host, false)
  xmlhttp.onload = function () {
    var elapsed_time = - start_time;
    console.log(region_data[i].name + ': ' + elapsed_time);

  // Send request

Hi there @jmarbach,

Usually you would be seeing the server IP address in case that you are using Nginx as a reverse proxy. To get the real IP address of the visitor you have to get the X-forwarded-for header value. That way you would get the actual IP rather than the server IP itself.

Hope that this helps! Regards, Bobby