Question

I'm developing a system that consists of a Php web server and a C# program. They both run on the same host. The web server receives data from clients (mobiles) then updates to a database and sometimes it should notify the C# program. To do this, I open a socket client on Php side then connect to a socket server on C# program side, like this:

(Php web server side)

1) process HTTP Request from clients

2) update data to database

3) if need to notify C# program (depending on received data)
    3.1) open a socket client (localhost, 8888)
    3.2) send data
    3.3) close socket

Until now, our system works quite well with small number of clients (for testing) but I'm not sure in case of large amount of clients.

Anyone can give me some comments to increase the performance!

Was it helpful?

Solution

Sockets are relatively very fast; related to using say message Q. Socket per se would not choke; your single C# program should be able to cope up with the load; else the messages would continue to pile up and eventually socket send calls would start backing up.

Message Q systems are systems designed to do what you are trying to do here - they provide a middleware that allows sending and receiving messages. They offer things like recovery, guaranteed deliver, allow you to scale out (by using say multiple receiver C# programs), etc. You can look at them.

If you are too worried about sockets performance, you could use some sort of interprocess communication, details of which are OS dependent. Things like shared memory, pipes etc. Usually all of them, including sockets, are fast enough that you would not notice much difference in normal routine use. The difference would be apparent only at very high rates .

You could also look at things like in memory databases. PHP writes it into in memory DB; C# program reads off the in memory DB

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top