GWT RPC - Multiple RPC Services Per App
I am currently working with a GWT app that has one large RPC service. It has over 100 methods, all of which do different things. What kind of performance benefit / hindrance would I get if I split this into multiple RPC services? I believe I'd have to make a new servlet for each one.
So my main questions are: Does GWT create a new RPC servlet for each running client? Would GWT have two servlets for one App if I have two RPC services? Would having two RPC services cause any performance issues. currently (10-15 concurrent users on one tomcat instance)
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.