0

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!

4

1 回答 1

1

套接字相对来说非常快;与使用说消息 Q 相关。套接字本身不会阻塞;您的单个 C# 程序应该能够应付负载;否则消息将继续堆积,最终套接字发送调用将开始备份。

Message Q 系统是设计用来做你在这里尝试做的事情的系统——它们提供了一个允许发送和接收消息的中间件。它们提供诸如恢复、保证交付、允许您横向扩展(通过使用多个接收器 C# 程序)等内容。您可以查看它们。

如果您太担心套接字的性能,您可以使用某种进程间通信,其细节取决于操作系统。诸如共享内存、管道等。通常所有这些,包括套接字,都足够快,以至于您在正常的日常使用中不会注意到太大的差异。只有在非常高的利率下,这种差异才会很明显。

您还可以查看内存数据库中的内容。PHP将其写入内存数据库;C# 程序读取内存中的 DB

于 2014-02-12T08:06:37.820 回答