PHP ve CPU - sohbet Süreci + bildirimleri

0 Cevap php

My site has a PHP process running, for each window/tab open, that runs in a maximum of 1 minute, and it returns notifications/chat messages/people online or offline. When JavaScript gets the output, it calls the same PHP process again and so on.
This is like Facebook chat.

Ancak, çalışırken çok fazla CPU alıyor gibi görünüyor. Facebook bu sorunu nasıl işleyeceğini aklında bir şey var mı? Onların süreçleri çok fazla CPU almak ve kendi sunucularını indirdi kalmamak ne yapmalıyım?

My process has a "while(true)", with a "sleep(1)" at the end. Inside the cycle, it checks for notifications, checks if one of the current online people got offline/changed status, reads unread messages, etc.
Let me know if you need more info about how my process works.

Does calling other PHPs from "system()" (and wait for its output) alleviate this?
I ask this because it makes other processes to check notifications, and flushes when finished, while the main PHP is just collecting the results.

Teşekkür ederim.

0 Cevap