/service-discovery

Service Discovery & Load Balancing service implementation using UDP broadcasting and TCP

Primary LanguageJavaMIT LicenseMIT

Logo

Service Discovery and Load Balancing Service

Service Discovery & Load Balancing service implementation using UDP broadcasting and TCP
Developed by Umutcan Sevdi, İsmet Güngör, Metin Usta and Emre Arslanoğlu.

Explore the docs »

Table of Contents
  1. Project Definition
  2. System Architecture
  3. Project Structure
  4. Performance Analysis
  5. Screenshots
  6. Installation
  7. Documentation
  8. License
  9. Contact

1- Project Definition

Service providing systems generally start as small-sized projects. However, over time they need methods to scale their systems to keep up with the incoming demand. Sometimes these scaling mechanisms are improved throughout the lifecycle of the application.

Systems require additional tools and structures for the future to keep providing services. One of these mechanisms is called Service Discovery. When the registry handling and the discovery are done by an additional server, it is called server-side service discovery.

Within the scope of our project, we will implement a server that combines the Service Registry and the Load Balancer. However, instead of storing service provider addresses in a database-like system, we will use UDP broadcasting to discover them.

2- System Architecture

The server and the client communicate through TCP. But the communication between server and service applications are done through UDP.

The client requests a service using TCP to the server. When the server receives the request sends a UDP broadcast message to all services. If the application services type matches the client's request, they respond to this message with their IP address, port number and a number corresponding to their busyness, using TCP.

data-animation

The server waits until the timeout and saves all responses during that time. After the timeout, the server analyzes all responses and selects the best service. Then sends its IP and port values to the client.

After that, the service application and client communicate directly through TCP.

data-animation

3- Structure

The project includes three applications:

  • Client is the application that represents the end-user. It sends the type of service application the user would like to interact with to the server and connects to the best available server. Then client application sends TCP requests to the application servers.
  • Server is the load balancer and the service discoverer. Upon receiving a TCP request from clients, searches given query using UDP broadcast and registers incoming requests. Selects the best available server and returns its address to the client.
  • Service is the service application. It represents backend applications in which clients interact. Upon receiving a UDP broadcast from the server, the service's UDP module responds to it with its load. Then it executes application programs for the clients.
service-discovery/
├── client
│   └── src
│       ├── data
│       │   └── Address.java
│       └── Main.java
├── server
│   └── src
│       ├── ApplicationServer.java
│       ├── data
│       │   ├── Address.java
│       │   └── ServerResponse.java
│       ├── exception
│       │   ├── NoResponseException.java
│       │   └── TimeoutException.java
│       ├── Main.java
│       └── UDPServer.java
└── service
    └── src
        ├── data
        │   ├── Address.java
        │   └── UDPRequest.java
        ├── exception
        │   └── InvalidRequestException.java
        ├── executor
        │   ├── DateTime.java
        │   ├── DNSLookup.java
        │   ├── Encryptor.java
        │   ├── EvaluateExpression.java
        │   └── Executor.java
        ├── GenericExecutionServer.java
        ├── Main.java
        └── UDPResponseServer.java

4- Performance Analysis

In this section, we examined our system's performance.

It is hard to determine the efficiency of such a system with arithmetic calculations. Using UDP broadcasting to determine services may look like it's creating an overhead. However, it also provides speed since it doesn't spend time on database transactions and data synchronizations.

It will also make adding new servers or removing existing ones easier. Adding new services will have little or no effect on the server's architecture.

4.1- Alternative Scenerio

When the system was initially designed, the server was also responsible for the data transfer between the client and the service. Although this creates anonymity over service applications, it was also causing an increase in the response time.

4.2- Revised System

In our system, the server is responsible for both server discovery and load balancing. So adding data transfer would cause heavyweight. To reduce its load, we changed the way our system works. When the load balancer detects the services, it returns its address information to the client. Then client directly connects to those services. This way server can perform data transfers more efficiently.

5- Screenshots

  • DNS Lookup service running on MacOS.

application-being-tested-on-macos

  • Encryption service running on MacOS.

application-being-tested-on-macos

6- Installation

  1. Clone the repo
   git clone https://github.com/umutsevdi/service-discovery.git
  1. Run following command to create Load Balance and Discovery server.
    java -jar out/server.jar
  1. Run following command on a seperate terminal to run client.
    java -jar out/client.jar
  1. Run following command on a seperate terminal to execute a service.
    java -jar out/service.jar --port 8083 --service DNS_LOOKUP

7- Documentation

Read the full documentation from here.

8- License

Distributed under the MIT License. See LICENSE for more information.

9- Contact

You can contact any developer of this project for any suggestion or information.

Project: umutsevdi/service-discovery

Developed by Umutcan Sevdi, İsmet Güngör, Metin Usta and Emre Arslanoğlu.