GWT RPC - Multiple RPC Services Per App

筅森魡賤 提交于 2019-12-04 09:20:13

What kind of performance benefit / hindrance would I get if I split this into multiple RPC services?

I believe it'd change nothing in this respect.

I believe I'd have to make a new servlet for each one.

Not necessarily. You could have a single RemoteServiceServlet implementing several RemoteService interfaces. You'd have to set the same @RemoteServiceRelativePath on all your interfaces for the client to use the same URL, but you could also map that same servlet to several distinct URLs (several servlet-mapping with the same servlet-name).

Does GWT create a new RPC servlet for each running client?

GWT doesn't create a new RPC servlet, if you host your web app in Tomcat, then Tomcat odes create servlet instances (generally a single instance per class).

One possible downside of multiple RPC interfaces: If you have many shared model objects between the interfaces, GWT will generate FieldSerializers for each model object - these will be shared correctly. However, in order to ensure that each RPC instance only references the serializers it needs, a TypeSerializer is created per service proxy. In the case of 10 services each using 100 model objects, this will result in 10 TypeSerializers, each with 100 FieldSerializer registrations (three components to each serializer - serialize, instantiate, deserialize).

I've seen at least one application almost triple in size under the weight of these shared model objects - over a hundred RPC interfaces, and thousands of possible model objects shared between them. Not every model was used in every interface, but enough were to do this kind of damage. This was mitigated by maintaining each interface pairs separately, and making one giant pair that extended each of the other interfaces - this way GWT.create is only invoked on that one type, and so only one giant TypeSerializer gets created instead of hundreds.

So keep an eye on your compiled output size, and check out the SOYC (Story Of Your Compile) report once in a while to see what takes up all the space.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!