-
Notifications
You must be signed in to change notification settings - Fork 1
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
nodejs作為server在超過24人連線時同步會產生延遲 #35
Comments
|
1.延遲是latency會在24人連線後數據同步時有100-200不等的延遲 28之後會開始飆升至1000 甚至更高 |
一個寫法的建議: 不過還是用Profiling的方式來確定問題會比較準。 |
cpu 使用率看起來不高,可以用 cluster module(mp2 的 cluster mode)來提高 cpu 使用率。用 cluster module 時,socket.io 的應該會需要用 redis adapter。 |
看起來慢的地方會在 js html 的部分,
這樣的寫法會造成越多人進來就算不是在同一個 group 裡面,但還是會不斷的收到所有訊息和資訊。
推測是因為用了 for loop 來處理前端資料,建議是拆開成不同 event listener 來處理,請愛用 event-driven
慢的感覺應該是前端感覺慢,並非伺服器的部分
Po-Ying Chen <[email protected]> 於 2020年1月5日 週日 下午6:45寫道:
… cpu 使用率看起來不高,可以用 cluster module(mp2 的 cluster mode)來提高 cpu 使用率。用 cluster
module 時,socket.io 的應該會需要用 redis adapter。
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#35?email_source=notifications&email_token=AACU5HYWY3HN3P6F6Q5G4BLQ4G225A5CNFSM4KCLBYF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIDTUVA#issuecomment-570899028>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACU5H22MWS7L2TAFV6IRMLQ4G225ANCNFSM4KCLBYFQ>
.
--
===================================
Caesar Chi.
Traveler and web developer.
Focus on open source group, member of Node.JS Taiwan Community.
About me,
http://about.me/clonn
|
感謝使用 Node.js Taiwan AMA,以下附上簡單提問範例供參考,請把內容改成你自己遇到的問題
目的
<<我希望做一個 多人上線的遊戲伺服器 ,達成即時同步的效果>>
使用的工具
<<我在 Windows 下使用 npm 安裝 node.js 10.16 >>
操作流程
<<我下了 node dive_server.js 運行>>
遇到的問題
<<少人連線的時候不會出現延遲,但是在超過24人連線之後她會出現延遲的現象>>
嘗試過的解法
<<我嘗試過把 變數減少,但是在運行超過28台主機的時候便會出現延遲>>
程式碼
data_object.js
dive_server.js
html js
The text was updated successfully, but these errors were encountered: