Dropwizard response time is slow for first request

51 views
Skip to first unread message

tuk

unread,
Feb 7, 2018, 9:04:59 AM2/7/18
to dropwizard-user

I am using dropwizard 1.0.2. I am observing the response time for the very first request is about 5.5 seconds and then the subsequent request is taking about 1 second.


The issue is something similar to the one discussed here .


Can some one let me know is this expected? If yes then is there a workaround?


If this is not expected can some one let me know how can I log the timings of various phases of request processing in dropwizard?


I have already verified the timings in my resource class (this is returning the response in about 800 ms)

Ryan Kennedy

unread,
Feb 7, 2018, 9:51:56 AM2/7/18
to dropwiz...@googlegroups.com
Anecdotally I would say it's not uncommon. If you add in time spent making your first socket connection to a database, for instance, and other first-time costs that aren't paid on server startup, it stands to reason that the first request won't be snappy compared to subsequent requests.

As a workaround you could consider "warming" your service up with some synthetic traffic before making it live for user requests (or maybe you have other ways of pre-warming things).

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Debraj Manna

unread,
Feb 7, 2018, 11:14:38 AM2/7/18
to dropwiz...@googlegroups.com, rcke...@gmail.com
Thanks Ryan.

Is there a way I can know which part is getting lazy initialized in server startup and taking time during the first request? Is it possible to log the timings of the various phase of request processing?

To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-user+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-user/5fzQMO1HwHI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-user+unsubscribe@googlegroups.com.

Steve Kradel

unread,
Feb 7, 2018, 2:55:05 PM2/7/18
to dropwizard-user
You could add logging to the resource constructor to check timestamps, for one.  Consider a connection pool to keep at least a few "hot" connections ready to go, whether those are connections to a database, HTTPS endpoint, or other systems.  Consider registering resource classes as eagerly-initialized singletons.  Dropwizard itself does not introduce any artificial or unexpected delays.


On Wednesday, February 7, 2018 at 11:14:38 AM UTC-5, tuk wrote:
Thanks Ryan.

Is there a way I can know which part is getting lazy initialized in server startup and taking time during the first request? Is it possible to log the timings of the various phase of request processing?
On Wed, Feb 7, 2018 at 8:21 PM, Ryan Kennedy <rcke...@gmail.com> wrote:
Anecdotally I would say it's not uncommon. If you add in time spent making your first socket connection to a database, for instance, and other first-time costs that aren't paid on server startup, it stands to reason that the first request won't be snappy compared to subsequent requests.

As a workaround you could consider "warming" your service up with some synthetic traffic before making it live for user requests (or maybe you have other ways of pre-warming things).

On Wed, Feb 7, 2018 at 2:05 PM tuk <subhara...@gmail.com> wrote:

I am using dropwizard 1.0.2. I am observing the response time for the very first request is about 5.5 seconds and then the subsequent request is taking about 1 second.


The issue is something similar to the one discussed here .


Can some one let me know is this expected? If yes then is there a workaround?


If this is not expected can some one let me know how can I log the timings of various phases of request processing in dropwizard?


I have already verified the timings in my resource class (this is returning the response in about 800 ms)

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "dropwizard-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dropwizard-user/5fzQMO1HwHI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dropwizard-us...@googlegroups.com.

Ryan Kennedy

unread,
Feb 7, 2018, 6:43:54 PM2/7/18
to Debraj Manna, dropwiz...@googlegroups.com
On Wed, Feb 7, 2018 at 4:14 PM Debraj Manna <subhara...@gmail.com> wrote:
Is there a way I can know which part is getting lazy initialized in server startup and taking time during the first request? Is it possible to log the timings of the various phase of request processing?

Start the service, attach and start a profiler, then send one request? The profiler should be able to tell you where the time is being spent.
Reply all
Reply to author
Forward
0 new messages