Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多个worker进程之间 共享数据 #242

Closed
gsmwork opened this issue Apr 21, 2015 · 4 comments
Closed

多个worker进程之间 共享数据 #242

gsmwork opened this issue Apr 21, 2015 · 4 comments

Comments

@gsmwork
Copy link

gsmwork commented Apr 21, 2015

启动的时候 启动多个worker进程,如果需要数据共享,是不是必须依赖第三方(redis、memcache之类的)?
比如我想做聊天服务器,有房间的概念,那么新来一个客户端,有可能落在其中一个worker进程中,当广播给某房间的所有用户时,没办法取到该房间的客户端列表

@swituo
Copy link

swituo commented Apr 23, 2015

进程间通讯的问题么~ 用另外的服务是最方便的了。消息队列比较适合聊天。

@byargv
Copy link

byargv commented May 15, 2015

swoole_table应该可以用起来
另外可以考虑共享内存

@toxmc
Copy link
Contributor

toxmc commented May 15, 2015

用$server->connection_list会返回所有TCP连接,而不仅仅是当前worker进程的TCP连接。

@matyhtf
Copy link
Member

matyhtf commented May 16, 2015

  1. 使用apcu, swoole_table, yac, shmop 等共享内存库
  2. 借助存储 redis, memcache, mysql
  3. 使用文件系统 读写文件,/dev/shm /tmp等内存文件系统速度更快
  4. 使用swoole_server->sendMessage接口

@matyhtf matyhtf closed this as completed May 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants