Re: [twsocket] 5000+ Connections TCP Server
I've been reading through the mail archieves and would like to know if there are any tips / example code for creating a TCP server that can handle high (5000+) simultaneous connections. It seems the method to assign upto 500 connections per thread seems to be the best method. Is there an example of how to develop the server so that a connection can be assigned to a certain thread. I assume the actual server runs on the main thread and assigns each connection to a thread as it connects. How is this managed and implemented? TWSocket has methods ThreadAttach and ThreadDetach to have a given socket work in the context of a given thread which is different than the thread which created TWSocket instance in the first place. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] 5000+ Connections TCP Server
> Potentially there will be 1000's of streams opening, sending data > and then closing evey 15 minuntes. So five seconds activity every 15 minutes from 1,000 streams, equals average six simultaneous connections, a doddle. 10,000 streams 60, still low. > Another possibility is to have multiple servers listening on > different ports. If this is a mission critical system with downtime not really allowed, multiple capture and database servers should be planned. But they should be on different physical or at least virtual machines, or a combination of the two. You can use round robin DNS to alternate between server IPs, or load sharing appliances. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] 5000+ Connections TCP Server
>> I've been reading through the mail archieves and would like to know >> if there are any tips / example code for creating a TCP server that >> can handle high (5000+) simultaneous connections. It seems the >> method to assign upto 500 connections per thread seems to be the >> best method. Is there an example of how to develop the server so >> that a connection can be assigned to a certain thread. > Not yet, but you are not the first to ask. The problem is ICS is written > and supported by volunteers, and unless those volunteers have new > projects that need new features, there needs to be an incentive for the > time needed to be allocated. >> My application is a server that will handle connections from many >> thousands on devices sending an XML stream (around 5 - 100k in >> size) at set intervals. This XML is stored to a DB for processing >> at a later date. It is likely that in the future there will be many >> thousands of these devices sending information. > Are you planning on writing thousands of streams to the database > simultaneously in real time, or is thousands of open and idle connections > sending XML once a minute, or once an hour or something? > Is this two way so the originator gets a response from the database, or > one-way so data is simply collected and can be queued before being > written. Potentially there will be 1000's of streams opening, sending data and then closing evey 15 minuntes. > Writing to a database is intensive, using ADO I believe each connection > uses it's own thread, so you can end up with thousands of threads running > on the server, in addition to your own threads. The data will be written to DB (file could be used if better performance) and confirmation sent back to the client indicating everything was stored correctly. > If you are only collecting data, you may want to look at my ComCap > application, which uses ICS to handle up to 400 streams using a single > thread, and will parse and write data from those streams to a SQL > database. It has been tested with 250 streams being written to files > (created by the related ComGen tool) but not 250 database connections! > http://www.magsys.co.uk/comcap/ > Angus Another possibility is to have multiple servers listening on different ports. If each server ran on a seperate thread would this increase load handling? The only problems is that all connections would be incoming to the same port so I'd need to redirect traffic from port x to the servers on port y / z depending on which server had enough free load. Is this something that is possible? -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] 5000+ Connections TCP Server
Hello, Aside from the DB part, supporting 10k connections was achieved by our web reverse proxy. Source code available but not for free: www.iqreverseproxy.com Best Regards, SZ On Mon, Sep 14, 2009 at 12:00 PM, Paul Howes wrote: > Hi, > > I've been reading through the mail archieves and would like to know if > there are any tips / example code for creating a TCP server that can handle > high (5000+) simultaneous connections. It seems the method to assign upto > 500 connections per thread seems to be the best method. Is there an example > of how to develop the server so that a connection can be assigned to a > certain thread. I assume the actual server runs on the main thread and > assigns each connection to a thread as it connects. How is this managed and > implemented? > > My application is a server that will handle connections from many thousands > on devices sending an XML stream (around 5 - 100k in size) at set intervals. > This XML is stored to a DB for processing at a later date. It is likely that > in the future there will be many thousands of these devices sending > information. > > It is intended that this will eventually run on a full server spec > multi-processor / core machine. > > Kings Regards, > Paul. > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] 5000+ Connections TCP Server
> I've been reading through the mail archieves and would like to know > if there are any tips / example code for creating a TCP server that > can handle high (5000+) simultaneous connections. It seems the > method to assign upto 500 connections per thread seems to be the > best method. Is there an example of how to develop the server so > that a connection can be assigned to a certain thread. Not yet, but you are not the first to ask. The problem is ICS is written and supported by volunteers, and unless those volunteers have new projects that need new features, there needs to be an incentive for the time needed to be allocated. > My application is a server that will handle connections from many > thousands on devices sending an XML stream (around 5 - 100k in > size) at set intervals. This XML is stored to a DB for processing > at a later date. It is likely that in the future there will be many > thousands of these devices sending information. Are you planning on writing thousands of streams to the database simultaneously in real time, or is thousands of open and idle connections sending XML once a minute, or once an hour or something? Is this two way so the originator gets a response from the database, or one-way so data is simply collected and can be queued before being written. Writing to a database is intensive, using ADO I believe each connection uses it's own thread, so you can end up with thousands of threads running on the server, in addition to your own threads. If you are only collecting data, you may want to look at my ComCap application, which uses ICS to handle up to 400 streams using a single thread, and will parse and write data from those streams to a SQL database. It has been tested with 250 streams being written to files (created by the related ComGen tool) but not 250 database connections! http://www.magsys.co.uk/comcap/ Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be