Skip to content

A Netty implementation to improve my original service heart beat monitor

Notifications You must be signed in to change notification settings

YiYeHuang/NettyHeartBeatMonitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NettyHeartBeatMonitor

A Netty implementation to improve my original service heart beat monitor, added additional persistent storage using Hazelcast

Intention

The request was coming from a interview long time ago. At the time I was trying to solve the problem with out any framework. The result with astonishingly bad. However, I still got the phone call from the company afterwards. You can see from the old implementation repo. The problem includes:

  • using old java io library, each call is blocking.
  • launching a thread per client, over 1000 client will pretty much kill the process
  • The central service has a hug loop and keep pinging the service, which is not every efficient
  • Client accessibility is bad
  • Multi-threading ability is a joke

New Implementation Structure

  dummy service -                                                                          | spring   | 
                  |                                --------------                          | boot     |
  dummy service   |>--- scheduled heart beat ---> | Netty Server |--> | Hazelcast Store|> -| rest     | <----user
                  |                                --------------                          | endpoint |
  dummy service -                                                                          | access   |

This implementation also uses Netty framework to deal with the networking work and the non-blocking io. This free up the threads and the resource to deal with more throughput. Hazelcast key value store is also used here for persistent in distributed environment. On the top, the access endpoint is represented using Spring Boot framework.

Improvement

  • Netty Framework prevent the blocking call
  • The Netty eventloop avoid too many threads being created
  • Using Java schedule service to schedule the heart beat rate, to avoid busy pinging.
  • Hazelcast key value store to make this design scalable.
  • Easy access with rest api

How to Test

  • Build the project
  • Launch the monitor server. This will start hazelcast -> netty -> Spring
  • Launch any numbers of client service you want.
  • access with localhost:8080/services for all current connected services
  • access with localhost:8080/monitor/${service name} for cpu and memory information

About

A Netty implementation to improve my original service heart beat monitor

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages