3

Node.js と Redis を使用して稼働時間監視システムを作成するための最適なソリューションは何ですか? Redis をキューとして使用できますが、情報を保存する最良の方法ではありません。おそらく MongoDB はそうですか?

かなり単純に思えますが、サーバーがダウンしていることを保証し、すべてを連携させるために複数のサーバーが必要になるのはそれほど簡単ではありません。

4

2 に答える 2

1

アップタイムを監視するには、システムで Cron ジョブを使用します。呼び出しごとに、ホストが起動しているかどうか、およびどれくらいの時間がかかるかを確認します。そのスクリプトでは、データを Redis に保存します。

Node.JS でこれを行うには、サーバーのステータスをチェックするスクリプトを作成します。サーバーへの HTTP リクエスト (または Ping、私たち) を作成し、失敗したかどうかを記録するだけです。次に、それを Redis に記録します。スクリプト (30 秒ごとに cron を実行する場合) は次の実行までに [30] 秒あるため、サーバーへのクエリの取得について心配する必要がないため、どのように実行するかは問題ではありません。データをどのように保存するかはあなた次第ですが、この場合は MySQL でも機能します (少数のサイトのみを実行している場合)。

Cron の詳細 @ ウィキペディア

于 2011-06-20T01:58:53.810 に答える
0

Can I use Redis as a queue but is not the best way to save information, maybe MongoDB is?

You can(should) use Redis as your queue. It is going to be extremely fast.

I also think it is going to be very good option to save the information inside Redis. Unfortunately Redis does not do any timing(yet). I think you could/should use Beanstalkd to put messages on the queue that get delivered when needed(every x seconds). I also think cron is not that a very good idea because you would be needing a lot of them and when using a queue you could do your work faster(share load among multiple processes) also.

Also I don't think you need that much memory to save everything in memory(makes site fast) because dataset is going to be relative simple. Even if you aren't able(smart to get more memory if you ask me) to fit entire dataset in memory you can rely on Redis's virtual memory.

It seems pretty simple but needing to have more than 1 server to guarantee the server is down and make everything work together is not so easy.

Sharding/replication is what I think you should read into to solve this problem(hard). Luckily Redis supports replication(sharding can also be achieved). MongoDB supports sharding/replication out of the box. To be honest I don't think you need sharding yet and your dataset is rather simple so Redis is going to be faster:

于 2011-06-21T00:14:37.350 に答える