Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scalable Delphi TCP server implementation

Tags:

delphi

Any suggestions for components to use as a base for a scalable TCP server? I currently have an implementation that uses Indy which works well for say 100 relatively active connections or 1,000 relatively inactive connections, but the one thread per connection model limits the number of concurrent active connections that can be handled.

Let's say my goal might be 1,000 connections each processing 10 messages per second or 10,000 connections each processing 1 message per second on a good server (8-16 cores). Is this realistic? I'd really like to hear of any real-world implementations because I have found that what might work in theory does not necessarily work in practice and I do not want to be chasing a proposed solution that will not work.

Edit: IOCP would be good, but I only want to use commercial-grade classes/components, so they need to be as "professional" as Indy or IP*Works before I would think of using them. Furthermore, I have no intention of "rolling my own" solution - it would take too much time to make it commercial-grade. Lastly, I am looking for a significant improvement on what I already have. I am sure I can squeeze at least 20-50% more out of what I have (based on Indy), but I am never going to be able to handle 10,000 concurrent clients, or 10,000 messages per second, no matter how hard I try. Whether there is something out there that meets these conditions is another matter.

I have decided to accept the answer referring to the IOCP classes, even though I have not used them, because they look like the best path for investigation at this stage.

like image 381
Misha Avatar asked Aug 22 '11 15:08

Misha


2 Answers

There is a project at http://voipobjects.com/ which is based on the former iopcclasses project.

It claims to handle thousands simultaneous connections:

IOCP engine is set of classes, components and routines for rapid creation high scalable and performance TCP/UDP applications. Application created using IOCP classes can handle thousands simultaneous connections.

Library is written in Delphi - Delphi 7 - 2010 are supported.

Library uses IO completion ports technology. There is most powerful technology in Win32 world for creation highly scalable and performance TCP/UDP applications. This technology is supported in all desktop Windows OSes except old Win9x/WinME versions.

This library is licensed under MPL1.1. Also It includes some files from Jedi project (Winsock2 header translation).

https://bitbucket.org/voipobjects/iocpengine

like image 187
mjn Avatar answered Oct 10 '22 11:10

mjn


My favorite Delphi network layer is ICS by Francois Piette. It's fantastically easy to understand, very scalable, and ultra-high performance. Free, and open source. Will probably scale to 1000 clients for most people, without significant effort, and without the complexity that gives me trouble when I use Indy.

I got about a 20% scalability/performance boost from switching all my stuff from Indy to ICS.

like image 33
Warren P Avatar answered Oct 10 '22 11:10

Warren P