Quyền lợi thành viên thường & thành viên Vip
Thành viên thường
Thành viên VIP
Học và làm bài tập 3 - 5 bài miễn phí (chọn sẵn) Tất cả (không giới hạn)
Xem đáp án, lời giải chi tiết
Làm bài kiểm tra Tất cả (không giới hạn)
Toán vui mỗi ngày
Toán vui mỗi tuần
Thi đấu kiến thức Không giới hạn
Hỏi đáp nhanh
Danh sách bạn bè Tối đa 50 bạn Tối đa 200 bạn
Xem bài giảng video
(Sắp ra mắt)
Xem toàn bộ, không giới hạn
Phí thành viên
Free 180.000 đ/năm
ĐĂNG KÝ VIP
Thành viên VIP sẽ được hưởng tất cả các quyền lợi VIP trong vòng 1 năm (365 ngày).
(học được tất cả các lớp, tất cả các môn có trên website)
Công nghệ
Multi-Instance Node.js App in PaaS Using Redis Pub/Sub
Xe đạp thông minh có khả năng theo dõi sức khỏe

Let's say you have a completely separated instance (worker dyno on Heroku) for doing more resource-eating work like complicated calculations, processing data in the database, or exchanging a lot of data with an external service. You will want the "normal" instances (and therefore the users) to know the result of this work when it's done.

If you chose PaaS as hosting for your application, you probably had or will have this problem: Your app is deployed to small "containers" (known as dynos in Heroku, or gears in OpenShift) and you want to scale it. In order to do so, you increase the number of containers—and every instance of your app is pretty much running in another virtual machine. This is good for a number of reasons, but it also means that the instances don't share memory.

The simplest example will just send information to other instances that you've just started. For example, you can display this information in the admin panel. Before we do anything, create another connection named client2. I will explain why we need it later.Let's start by just sending the message that we started. It's done using the publish() method of the client. It takes two arguments: the channel we want to send the message to, and the message's text:


loading...
Tag:
Bình luận - hỏi đáp:
Đã có 0 bình luận
Danh mục kiến thức