Assignment:1
Backend System Design Using Queue
Objective: Design and implement a backend system that efficiently manages
requests from multiple users using a queue structure. Each client connected
will have its queue where all requests will be processed sequentially. The
system should be robust and scalable, ensuring that the queue is empty once
all requests are processed and all users disconnect.
Requirements:
1. User Authentication : Securely authenticate users before they can
enqueue requests.
2. Request Queueing : Implement a queue for each client to handle requests
in a First-In-First-Out (FIFO) manner.
3. Request Processing : Develop a process to handle and execute requests
sequentially.
4. Concurrency Management : Handle multiple clients and their queues
concurrently.
5. Scalability : Ensure the system can scale to handle an increasing number
of users and requests without degradation in performance.
6. Robustness : Implement error handling and recovery mechanisms to manage
failures without data loss.
7. Logging and Monitoring : Set up logging for tracking request handling
and system monitoring for performance metrics.
Tools and Technologies:
- Programming Language : Node.js
- Messaging/Queueing System : RabbitMQ / Redis / Kafka
- Database : PostgreSQL / MongoDB
- Monitoring Tools : Prometheus, Grafana
System Design:
- Client-Server Model : Users interact with the system through a client
interface that sends requests to the server.
- Queue Management : Each client connection has a dedicated queue. A queue
manager handles the creation, management, and deletion of queues.
- Worker Processes : Dedicated worker processes pull requests from queues
and execute them sequentially.
Assignment Tasks:
1. System Architecture :
- Draw a system architecture diagram showing the client-server model,
queue system, database, and worker processes.
2. Implementation :
- Implement user authentication.
- Setup the queue for each client.
- Create worker processes that execute tasks from the queue.
3. Testing :
- Write unit tests to verify the system's functionality under various
scenarios.
4. Deployment :
- Prepare a deployment plan using Docker containers for each component
of the system.
Flow Diagrams:
1. Overall System Flow :
- Diagram showing the interaction between users, client interface,
server, queues, and workers.
2. Detailed Process Flow :
- A detailed diagram of how requests are received, authenticated,
queued, processed, and logged.
Submission Requirements:
- Source code for all components.
- Dockerfiles for building container images.
- System and process flow diagrams.
- Test cases and results.
- Documentation explaining the system architecture and code.
Assignment 2 :-
Backend Assignment: Flow Distribution Algorithm
Overview
In this assignment, you'll be tasked with designing and implementing a flow
distribution algorithm in Node.js for connecting users with astrologers.
The goal is to ensure that each astrologer gets an equal proportion of
chances to connect with users, while also providing the flexibility to
adjust flow for top astrologers.
Requirements
1. Design a flow distribution algorithm that allocates users to astrologers
in a fair and balanced manner.
2. Implement a mechanism to toggle the flow for top astrologers, allowing
them to receive more or fewer connections as desired.
3. Ensure that the algorithm can handle a daily flow of 2000-3000 users and
a pool of 500 astrologers efficiently.
4. Provide clear documentation explaining the logic behind your algorithm
and how to use it.
5. Write test cases to validate the functionality of your algorithm.
Implementation Steps
1. Data Structure : Define data structures to represent astrologers and
users, including their attributes and current flow status.
2. Algorithm Design :
- Implement a fair distribution algorithm that evenly distributes users
among astrologers.
- Incorporate a mechanism to adjust the flow for top astrologers based
on user preferences.
3. API Design :
- Create RESTful endpoints for controlling the flow distribution and
toggling settings for top astrologers.
4. Backend Implementation :
- Develop the backend logic in Node.js using Express.js or any other
preferred framework.
- Integrate the algorithm into the backend system to handle user
requests and manage flow distribution.
5. Documentation :
- Write comprehensive documentation explaining the flow distribution
algorithm, its design principles, and how to interact with the API
endpoints.
6. Testing :
- Write unit tests to ensure the correctness of the algorithm and its
behavior under various scenarios, including different user loads and
settings for top astrologers.
Deliverables
- Node.js backend code implementing the flow distribution algorithm.
- API documentation detailing how to interact with the backend endpoints.
- Test cases to validate the functionality of the algorithm.
- Documentation explaining the logic behind the algorithm and its design
considerations.
Additional Considerations
- Scalability: Ensure that the algorithm can scale efficiently as the
number of users and astrologers grows.
- Performance: Optimize the algorithm and backend implementation for
performance to handle the expected user flow.
- Security: Implement appropriate security measures to protect sensitive
data and prevent unauthorized access to the system.
Conclusion
This assignment will test your ability to design and implement a flow
distribution algorithm that balances fairness with flexibility in a real-
world application scenario. Good luck!