Java Grizzly HTTP Server working to capacity 100% CPU usage on some threads

178 Views Asked by At

Im using the Grizzly Http Server on my webserver to serve a REST API. After some time the server is working more and more to full capacity even there are no more users online.

In htop i can see that there are some grizzly http threads (at this time in the picture one) which are using 100% of one kernal. How is that possible? Any ideas?

Code:

/* IMPORTS */

public class WebAppServer {

    private static WebAppServer instance;

    public static WebAppServer getInstance() {
        if (instance == null) instance = new WebAppServer();
        return instance;
    }

    public void start() throws IOException, URISyntaxException {
        String baseUrl = MavenPropertyDao.getInstance().getProperty(MavenPropertyDao.REST_SERVER_URL);
        ResourceConfig rc = new MyConfig();
        rc.register(new CORSFilter());
        rc.registerClasses(/* REST CLASSES */);
        final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(new URI(baseUrl), rc);
        Runtime.getRuntime().addShutdownHook(new Thread(server::stop));
        server.start();
    }


    public class MyConfig extends ResourceConfig {
        public MyConfig() {
            register(new HttpExceptionHandler());
            register(MultiPartFeature.class);
            register(GsonProvider.class);
            property(ServerProperties.MONITORING_STATISTICS_ENABLED, true);
        }
    }

}

htop after a day: enter image description here

0

There are 0 best solutions below