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 <[email protected] > <javascript:>> 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 <[email protected] <javascript:>> >> 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 >>> <https://stackoverflow.com/questions/48665778/dropwizard-response-time-is-slow-for-first-request> >>> . >>> >>> >>> 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 [email protected] <javascript:>. >>> 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 >> [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
