Issue with slow API response time on GET calls.

Posted August 7, 2020 1.8k views

Hey, I’m trying to migrate from Heroku to DigitalOcean with my simple Spring Boot API based on MongoDB (mLab).

My metrics are ok, just Disk Usage looks strange (Always 100%)
Link to metrics: Metrics CPU and memory and Disk Metrics

On Heroku with the worst CPU and memory, I have x4 faster response on GET calls with the same codebase. POST and PUT calls are ok or even better on DigitalOcean.

Old Heroku API call: Result here
New DigitalOcean API call: Result here

What is the difference between these two servers that make such degradation in performance?
What steps should I do to fix it?
Please, can somebody help me with that?

I can give more info if necessary.

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.

Submit an Answer
2 answers

Hi there @chichideveloper,

As far as I can see the Heroku IP was based in Dublin but the DigitalOcean IP that you’ve shared is in California, the latency could explain the extra time that you are seeing.

What I could suggest is either creating a Droplet in a region that is closer physically to you, or what you could do is use a CDN like Cloudflare to reduce the latency in general.

Let me know how it goes.

  • Hi Bobby, thank you for your reply.

    Unfortunately, my server already located in Frankfurt (FRA1) which is even closer than Dublin (Heroku).

    I have noticed that there are a lot of differences in headers here:

    Old Heroku API call: Result here
    New DigitalOcean API call: Result here

    For example, DigitalOcean call doesn’t have Server, Via, Transfer-Encoding, Connection headers.

    • Hi there @chichideveloper,

      Regarding the disk usage, if you log in to the server and run df -h what is the disk usage reported there?

      Also how large was the disk space on your Heroku server compared to your new server?

      Another thing that comes to my mind is the webserver settings and version, have you verified that they are both the same on both servers?


      • Hi there Bobby, thank you for your answer.

        Disk usage (df -h): Link to image

        My Heroku server is x2 smaller than DigitalOcean. (Hobby Dyno 512 Mb Memory, 1 CPU) vs DO (2 GB Memory / 50 GB Disk ):

        I have checked webserver here and figure out that they are not similar.

        Heroku webserver: Result
        DO webserver: Result

        Heroku server is Cowboy but DO is Unknown. Do I need to install web server separately?
        I use Ubuntu Docker 5:19.03.1~3 on 18.04.

        I have just deployed my Docker image without any changes to the server.

        Please, can you explain, do I need to install web server and what settings should be implemented on the server to make at least the same performance.

        Thank you!

        • I have resolved the issue with 100% disk by removing the container and deploy once again with docker image prune.

          Performance is still bad as mentioned above.

          • Hi there,

            Indeed it looks like the different web server that you are suing currently could be causing the delay.

            Which guide did you follow in order to set up the server on the DigitalOcean end?

            You could try using the same Cowboy web server as you did with your Heroku server and see how it performs.

            Let me know how it goes.

Hi there,

I have chosen a Droplet with already installed Docker, make configuration of Certificates and that is it.
After that, I just deploy my Spring Boot with Dockerfile.

As I know, Spring boot has Apache inside, so I didn’t install it, have no idea why it’s showing Cowboy on Heroku and nothing on Digital Ocean (server header).

Do I need more configuration or installations to make ready to go Droplet with Docker?

Thank you,!