java - Interview question, 100,000 devices are required to check the online status. What technology should be used?
大家讲道理
大家讲道理 2017-05-17 09:57:38
0
9
817

I don’t know much about high concurrency, how should I deal with it? Are there any introductory books on high concurrency?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(9)
漂亮男人

Use TCP long connection directly~ Smart homes generally have more MQTT protocols~~
Long connection saves too many resources than polling~
It can still be implemented in a stand-alone situation. Of course, counting the database is another matter.

过去多啦不再A梦

I want to test your understanding of distributed architecture here. This question should be to test your understanding of 服务发现(service discovery)的认识。分布式就是把一个大型项目进行模块化拆分,然后各模块在做集群部署,前端有一个路由服务器来对到达的请求进行分发,把到达的请求路由到能够提供服务的服务端,而哪台服务器能够提供服务这就是服务发现所要做的事情,而在集群环境下能够提供相等服务的服务器肯定不止一台,那到底该由那台服务器对用户的请求进行处理并响应呢?这就又引出了负载均衡,由负载均衡层通过特定的算法来判断应该由那台服务器提供服务,目的就是均匀的把请求分发给各个服务端。服务发现可以了解下Apache的zookeeper或者Netflix的Eureka。微服务这块spring cloud提供了全套的解决方案,还有阿里的dubbo

大家讲道理

Distributed session management

習慣沉默

I have a simple solution
Install an agent process for the device. The process is started when the device starts, and then the process actively reports the device status to the server regularly. If no report is made after a certain period, the device is considered offline

洪涛

High concurrency, asynchronous communication. java words. . . Classic netty?
In my personal opinion, according to the current single-machine performance, a single machine can support 100k concurrent operations. Distributed processing is not a necessary option. Of course, if you include database storage, it will be another matter.

phpcn_u1582

If long connections are not considered, there is an idea to use redis to set an online flag for each device and set a valid time. The client refreshes the valid time every time it makes an uplink request, and counts the number of redis online status devices each time. The key here is how to determine the length of this time because I have always been working on the backend. I don’t know how long the client can stay online when it is inactive. Is there something like a daemon?

伊谢尔伦

Storing data in redis, access is faster than db

黄舟

If it were me, I would do this:
Create a new MySQL memory table (ENGINE=MEMORY):
online(user_id, update_time)
Use update_time to record the user’s latest access time.
For example, you can assume that all users within 5 minutes will think Online.

習慣沉默

It can be implemented in layers. For example, for example, 100,000 machines report their status to 10 machines respectively. How do 100,000 machines correspond to 10 machines? You can use hash mapping, and then these 10 machines will report the faulty machines. Report the situation to a fixed host, which roughly means 10w-->10-->1. The above example may have a single point of failure, which can be solved by changing the number of upper-layer machines

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!