Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can socket connections be multiplexed?

Is it possible to multiplex sa ocket connection?

I need to establish multiple connections to yahoo messenger and i am looking for a way to do this efficiently without having to hold a socket open for each client connection.

so far i have to use one socket for each client and this does not scale well above 50,000 connections.

oh, my solution is for a TELCO, so i need to at least hit 250,000 to 500,000 connections

i'm planing to bind multiple IP addresses to a single NIC to beat the 65k port restriction per IP address.

Please i would any help, insight i can get.

**most of my other questions on this site have gone un-answered :) **

Thanks

like image 411
Charles Okwuagwu Avatar asked Mar 20 '09 10:03

Charles Okwuagwu


2 Answers

This is an interesting question about scaling in a serious situation.

You are essentially asking, "How do I establish N connections to an internet service, where N is >= 250,000".

The only way to do this effectively and efficiently is to cluster. You cannot do this on a single host, so you will need to be able to fragment and partition your client base into a number of different servers, so that each is only handling a subset.

The idea would be for a single server to hold open as few connections as possible (spreading out the connectivity evenly) while holding enough connections to make whatever service you're hosting viable by keeping inter-server communication to a minimum level. This will mean that any two connections that are related (such as two accounts that talk to each other a lot) will have to be on the same host.

You will need servers and network infrastructure that can handle this. You will need a subnet of ip addresses, each server will have to have stateless communication with the internet (i.e. your router will not be doing any NAT in order to not have to track 250,000+ connections).

You will have to talk to AOL. There is no way that AOL will be able to handle this level of connectivity without considering cutting your connection off. Any service of this scale would have to be negotiated with AOL so both you and they would be able to handle the connectivity.

There are i/o multiplexing technologies that you should investigate. Kqueue and epoll come to mind.

In order to write this massively concurrent and teleco grade solution, I would recommend investigating erlang. Erlang is designed for situations such as these (multi-server, massively-multi-client, massively-multithreaded telecommunications grade software). It is currently used for running Ericsson telephone exchanges.

like image 185
Jerub Avatar answered Sep 30 '22 04:09

Jerub


While you can listen on a socket for multiple incoming connection requests, when the connection is established, it connects a unique port on the server to a unique port on the client. In order to multiplex a connection, you need to control both ends of the pipe and have a protocol that allows you to switch contexts from one virtual connection to another or use a stateless protocol that doesn't care about the client's identity. In the former case you'd need to implement it in the application layer so that you could reuse existing connections. In the latter case you could get by using a proxy that keeps track of which server response goes to which client. Since you're connecting to Yahoo Messenger, I don't think you'll be able to do this since it requires an authenticated connection and it assumes that each connection corresponds to a single user.

like image 29
tvanfosson Avatar answered Sep 30 '22 04:09

tvanfosson