0

I'm implementing a Java RESTful webservice on Heroku. Currently my entry point looks like

public class Main
{

    public static final String BASE_URI = getBaseURI();

    public static void main( String[] args ) throws Exception
    {
        final Map<String, String> initParams = new HashMap<String, String>();
        initParams.put( "com.sun.jersey.config.property.packages", "services.contracts" );
        initParams.put( "com.sun.jersey.api.json.POJOMappingFeature", "true" );

        System.out.println( "Starting grizzly..." );
        SelectorThread threadSelector =
        GrizzlyWebContainerFactory.create( BASE_URI, initParams );

        System.out.println( String.format( "Jersey started with WADL available at %sapplication.wadl.", BASE_URI,
                BASE_URI ) );
    }

    private static String getBaseURI()
    {
        return "http://localhost:" + ( System.getenv( "PORT" ) != null ? System.getenv( "PORT" ) : "9998" ) + "/";
    }

}

where the initParms contains RESTful services being hosted. I understand that GrizzlyWebContainerFactory.create() returns an instance of ServletContainer (SelectorThread), but how would I multithread the returned threadSelector such that multiple SelectorThread's can handle the incoming requests under one process (aka web dyno)? The reason is to increase performance of a single dyno in handling requests.

Any suggestions appreciated! Thanks!

Luke
  • 1,053
  • 2
  • 16
  • 26

1 Answers1

0

You can call:

SelectorThread.setSelectorReadThreadsCount(int)
rlubke
  • 965
  • 5
  • 14