3

I have a Web Service (classes generated from WSDL), i need to publish the same service on many ports (like on localhost:10000,10001,10002,10003 etc., more than one thousand!), every port represents one 'device'. If i use

Endpoint.publish(); 

method, it takes almost 1 second to create one endpoint.

Is there another way to do it ?

razor
  • 2,727
  • 6
  • 33
  • 45
  • You could thread it, but you're registering with the kernel, so there will be a speed limit. More importantly, though, _why_ would you setup different ports per device? I expect the desire to configure this way is the actual problem and that you probably have better options. – user1676075 Jul 06 '18 at 15:28
  • it'll be proxy for many devices (thru one server or few if there are limits), but the rule is - one device - one address (it's like IP camera), and i need to proxy/share even few thousands of devices. – razor Jul 06 '18 at 16:05
  • But again, why would that be the rule? Web services are stateless. If I need to know the source, I can do that by querying the request, or you add a UUID to each device to include in the request, then map on the back end, but still listen via a single port. – user1676075 Jul 06 '18 at 17:35
  • one device - one endpoint (port), that's the only way to recognize device/call. yes, i can thread it - it'll speed up creation, but it'll still take a lot of resources... – razor Jul 09 '18 at 08:54
  • devices were created in a one way/that way (they don't have any IDs) and you can't change it. one host/port - one device – razor Jul 09 '18 at 09:51
  • I've just tested with many threads. Endpoint.publish had to have some inner synchronisation (single threaded code), as the creation speed is the same (even a bit slower) if i create 20 endpoints with 1 thread, or 2,4,8 (for tests). on e decent i7-6700 +32GB RAM machine – razor Jul 09 '18 at 11:02
  • 1
    Still skeptical; but another alternative you might consider is using nginx, configure that to listen on all ports, then send to your single service, adding a parameter in the rewrite to indicate the source port. – user1676075 Jul 09 '18 at 11:53
  • parameter -Dcom.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.fastBoot=true massively speeded up (more than ten fold) the process (after profiling i found a bottleneck - jaxbcontext initialization) – razor Jul 09 '18 at 12:05
  • I also configured nginx to forward connection (with proxy_set_header to save info about port), We'll see later which way is easier to maintain and less resource hungry – razor Jul 09 '18 at 21:20

0 Answers0