Multiple ajax request are slow

25 views
Skip to first unread message

Jean Boudet

unread,
Aug 3, 2015, 7:21:25 AM8/3/15
to play-framework

I have an rest api with Play 2.3.x on a Docker container. This api speak with PostgresSQL 9.4 database (on a Docker container too) and serves JSON. Client is a isomorphic app with React (on Docker container too).

When client change route, several request is send to the api. The problem is that every request is abnormally slow. For example, I have this uri:


GET /api/taxon/185214/geojson


When I send this request directly since the browser, response is shown at the end of 4s. When this request is send with other request, it takes 12s longer.

What can cause this time ?

Of course, every action of api are async. For example, geojson action:


public static Promise<Result> showGeoJson(final Long id)
{
   
Promise<GeoJsonModel> promise = F.Promise.promise(
           
new Function0<GeoJsonModel>() {
               
public GeoJsonModel apply() {
                   
// Get data with ebean
                   
return geojson;
               
}
           
}
   
);

   
return promise.map(
       
new Function<GeoJsonModel, Result>() {
           
public Result apply(GeoJsonModel geojson) {
               
// return Result
           
}
       
}
   
);
}


Does each request should be treated in another thread ?

Reply all
Reply to author
Forward
0 new messages