Giter VIP home page Giter VIP logo

Comments (4)

MihhailSokolov avatar MihhailSokolov commented on August 29, 2024 1

Consider using h2load or JMeter for load testing when most of the stuff is done.

from fasten.

MihhailSokolov avatar MihhailSokolov commented on August 29, 2024 1

@MihhailSokolov

With Spring's embedded Tomcat, it'll be possible with a simple server.tomcat.max-threads=20 in the server configuration file.

Done in 6d5a9a6

from fasten.

marcomicera avatar marcomicera commented on August 29, 2024

Our REST API only has GET endpoints, so we don't have to worry about data consistency.

As far as concurrency is concerned, I haven't found clear evidence that RESTeasy handles concurrent requests in separate threads. Moreover, the documentation suggests using asynchronous HTTP request processing in these cases:

The primary use case for Asynchronous HTTP is in the case where the client is polling the server for a delayed response. The usual example is an AJAX chat client where you want to push/pull from both the client and the server. These scenarios have the client blocking a long time on the server’s socket waiting for a new message.

I don't think this is our case though.

(in fact using asynchronous processing may actually hurt your performance in most common scenarios)


We can still come up with a stress test and compare our current implementation with a multithreaded one.
Practically, this could be achieved by running endpoints' logic into separate threads, so this:

@GET
@Path("/{pkg}/{pkg_ver}/files")
@Produces(MediaType.APPLICATION_JSON)
public Response getPackageFiles(@PathParam("pkg") String package_name,
@PathParam("pkg_ver") String package_version,
@DefaultValue("0")
@QueryParam("offset") short offset,
@DefaultValue(RestApplication.DEFAULT_PAGE_SIZE)
@QueryParam("limit") short limit) {
return service.getPackageFiles(package_name, package_version, offset, limit);
}

Might turn into this (tested & working):

@GET
@Path("/{pkg}/{pkg_ver}/files")
@Produces(MediaType.APPLICATION_JSON)
public void getPackageFiles(@Suspended final AsyncResponse response,
                            @PathParam("pkg") String package_name,
                            @PathParam("pkg_ver") String package_version,
                            @DefaultValue("0")
                            @QueryParam("offset") short offset,
                            @DefaultValue(RestApplication.DEFAULT_PAGE_SIZE)
                            @QueryParam("limit") short limit) {
    new Thread(() -> {
        Response result = service.getPackageFiles(package_name, package_version, offset, limit);
        response.resume(result);
    }).start();
}

Our endpoints wouldn't be returning Response objects anymore, but clients would have to pass AsyncResponses as arguments.

from fasten.

marcomicera avatar marcomicera commented on August 29, 2024

@MihhailSokolov

With Spring's embedded Tomcat, it'll be possible with a simple server.tomcat.max-threads=20 in the server configuration file.

from fasten.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.