我正在Heroku上实现Java RESTful Web服务。目前我的入口点似乎是
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" ) + "/";
}
}
其中initParms
包含托管的RESTful服务。我理解GrizzlyWebContainerFactory.create()返回ServletContainer
(SelectorThread
)的实例,但我如何多线程返回的threadSelector
,以便多个SelectorThread
可以处理一个进程下的传入请求(又名web dyno)?原因是在处理请求时提高单个dyno的性能。
任何建议表示赞赏!谢谢!
答案 0 :(得分:0)
您可以致电:
SelectorThread.setSelectorReadThreadsCount(int)