Mock Test For Backend Lead (NodeJS)
Mock Test For Backend Lead (NodeJS)
Introduction
You can use your own IDE, but reference to external resources such as Google, ChatGPT,
and Stack Overflow is not allowed.
Full Description:
You are tasked with designing and implementing a NodeJS service that processes user
registration data from an HTTP API. The service must validate the incoming data, store it in
a database, and send a confirmation email to the user.
Service Requirements:
Implementation Constraints:
Evaluation Criteria:
● Correctness: The service must correctly validate, store, and "send" confirmation
emails.
● Code Quality: The implementation should be clean, well-documented, and easy to
understand.
● Error Handling: The service should handle invalid input gracefully, returning
appropriate HTTP status codes.
Mock Question 1.2
Full Description:
You are tasked with designing a scalable and resilient architecture for a content delivery
network (CDN) service. The CDN must efficiently serve a large number of static assets like
images, CSS files, and JavaScript files to users across the globe.
Design Considerations:
● Service Modularization: How would you break down the CDN into individual
components or services? List the services and explain their functionality.
● Caching Mechanisms: Describe how you would implement caching to ensure fast
delivery of content. Include strategies for caching at different levels (e.g., edge,
origin).
● Redundancy and Failover: Discuss how you would ensure the CDN remains
available even if some servers fail.
● Data Consistency: Explain how you would ensure that all users receive the most
up-to-date content, especially when changes are made.
Provide a detailed explanation for each aspect. Use examples where necessary to illustrate
your points.
Full Description:
Implement a Node.js service that demonstrates the use of streams and file handling. The
service should read a large text file, compress it, and save the compressed file to disk.
Requirements:
● Create an HTTP server using the http module that listens on port 3000.
● When a request is received on the endpoint /compress, the server should read a
specified large text file, compress it using a suitable compression algorithm, and save
the compressed file to the disk.
● The server should handle large files efficiently using streams to prevent high memory
usage.
Performance Measures:
● Correctness: The server must correctly compress and save the file.
● Efficiency: The server should handle large files efficiently without using excessive
memory.
● Code Quality: The clarity, structure, and comments in your code.
Constraints:
● Use the fs and zlib modules for file handling and compression.
● Handle errors gracefully, including issues with file access and compression.
Full Description:
You are provided with a MongoDB collection named users, which contains documents
representing user profiles. Each document has the following structure: { _id: ObjectId,
username: String, age: Number, joinedDate: Date }. Your task is to:
● Write a MongoDB query to retrieve the top 5 youngest users who joined in the last
year.
● Discuss the indexing strategies you would employ to optimize this query. Consider
the performance implications for both the write and read operations.
Write your query and discussion in plain text or code format below.
Full Description:
You are managing a NoSQL database system that stores large volumes of real-time IoT
data. Discuss the best practices for managing and querying time-series data in a MongoDB
database to maintain performance and efficiency. Your response should include strategies
for data partitioning, index management, and any relevant MongoDB features or tools.
Provide a thorough explanation of each practice and its benefits.
Full Description:
You are tasked with implementing a performance monitoring system in NodeJS for tracking
API response times. The system should log the response times of each API request and
generate alerts if the response time exceeds a certain threshold.
Specific Requirements:
Evaluation Criteria:
● Correctness: The monitoring system must accurately log and report response times.
● Code Quality: The implementation should be modular, well-documented, and easy to
extend.
● Efficiency: The monitoring system should not significantly impact the server's
performance.