vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

Register a handler to multiple addresses in a single request

Open j2ro opened this issue 13 years ago • 10 comments

It would be really useful if we could register multiple handlers to a single address in a single request:

e.g. eb.registerHandler('conv_gbp_eur, conv_gbp_usd', handler);

At the moment, we have to send a single request per registration:

e.g. eb.registerHandler('conv_gbp_eur', handler); eb.registerHandler('conv_gbp_usd', handler);

Being able to do this in a single request would enable us to significantly reduce bandwidth and performance overhead due to network latency.

j2ro avatar May 08 '13 11:05 j2ro

I don't understand why this would "significantly reduce bandwidth"? Can you explain?

purplefox avatar May 08 '13 12:05 purplefox

If we send the following two requests:

eb.registerHandler('conv_gbp_eur', handler); eb.registerHandler('conv_gbp_usd', handler);

This generates the following websocket traffic, and has an overhead of approximately 108 bytes (2*54 bytes): "{"type":"register","address":"conv_gbp_eur"}" "{"type":"register","address":"conv_gbp_usd"}"

With a single request:

eb.registerHandler('conv_gbp_eur, conv_gbp_usd', handler);

We have an overhead of approximately 67 bytes (only 13 bytes more). This generates the following message on the websocket: "{"type":"register","address":"conv_gbp_eur,conv_gbp_usd"}"

I am aware that this sounds like very small amounts of data (a difference of only 41 bytes). However, in the real world, we anticipate that each client will be registering around 300-500 addresses each, potentially re-registering to different addresses several times a minute. In addition, we are designing our system to cope with 10,000+ simultaneous clients. So that 41 bytes difference on each additional subscription quickly adds up.

j2ro avatar May 08 '13 12:05 j2ro

Its still quite low me thinks, but the method signature looks better when registering the same handler to different addresses

winash avatar May 08 '13 12:05 winash

I don't think its so low. Imagine the following scenario:

Number of clients: 10,000 Number of registered addresses per client: 500 Number of address re-registrations per minute: 3 Difference in message size: 41 bytes

Theoretically the additional bandwidth required to support this would be: 10000 x 500 x 3 x 41 = 615000000 bytes per minute = 586.5 megabytes per minute.

Admittedly, the example given is an extreme example, and we wouldn't expect load at this level every day. However, we would certainly expect this type of load from time to time (probably a handful of times per year). Furthermore, one of the main drives of our project is to reduce bandwidth, so anything that can be done to reduce this network overhead as far as possible is of benefit to us.

j2ro avatar May 08 '13 13:05 j2ro

If 10000 clients register 10 times a minute at 41 bytes a time.

That's only about 68KB per second.

That's less than 0.05% of the bandwith of a basic Gigabit network, and most people use 10 Gib these days, and it's less than 0.005% of the bandwidth of that.

purplefox avatar May 08 '13 13:05 purplefox

Your calculation is not right. According to what you said you have 3 registrations per minute, not 500 * 3 (1500)!

But even if you do have 1500 registrations per minute, that's only 10MB per sec. Which is still tiny.

Your bottleneck here won't be the network, if anything it will be GC.

purplefox avatar May 08 '13 13:05 purplefox

No, 3 sets of 500 registrations - i.e. 1500 registrations per minute.

Our application consists of a website with around 500 unique observable items on each page which we want to listen to. If a user changes the page on average 3 times per minute, then we end up with 1500 registrations per minute.

The users of the website will be accessing it over the internet, and not on an internal Gigabit network. Therefore the bandwidth we use is limited, and (according to the last bill from our ISP) is not free ;-).

j2ro avatar May 08 '13 13:05 j2ro

Can you please reopen?

j2ro avatar May 08 '13 14:05 j2ro

Can this be reopened and put in mayhaps or 2.1.0?

j2ro avatar May 09 '13 10:05 j2ro

I'll put it in the mayhaps, but I can't see a strong argument for it yet.

purplefox avatar May 09 '13 10:05 purplefox