0% found this document useful (0 votes)
40 views4 pages

Mock Test For Backend Lead (NodeJS)

Uploaded by

olivanderwood99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

Mock Test For Backend Lead (NodeJS)

Uploaded by

olivanderwood99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Mock Test for Backend Lead (NodeJS)

Total time: 135 minutes • Total score: 135 points

Introduction

You can use your own IDE, but reference to external resources such as Google, ChatGPT,
and Stack Overflow is not allowed.

Section 1: NodeJS Development and System Architecture

Time: 80 min • Score: 80

Mock Question 1.1

Time: 30 min • Score: 30 Type: Code Implementation

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:

● The service should expose an HTTP POST endpoint /register.


● The incoming request body will be a JSON object containing username (string),
email (string), and password (string).
● Validate the input: username should be alphanumeric, email should be in a valid
format, and password should be at least 8 characters long.
● Store the valid user data in an in-memory data store (you can use a simple
JavaScript object for this purpose).
● Simulate sending an email by logging the confirmation message to the console.

Implementation Constraints:

● Use only built-in NodeJS modules.


● Do not use any external libraries for validation or email handling.

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

Time: 20 min • Score: 20 Type: Design

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.

Mock Question 1.3

Time: 30 min • Score: 30 Type: Code Implementation

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.

Section 2: Database Management and Optimization

Time: 25 min • Score: 25

Mock Question 2.1

Time: 15 min • Score: 15 Type: Code Implementation

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.

Mock Question 2.2

Time: 10 min • Score: 10 Type: Explanation

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.

Section 3: System Monitoring and Debugging

Time: 30 min • Score: 30

Mock Question 3.1


Time: 30 min • Score: 30 Type: Code Implementation

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:

● Implement a simple NodeJS server with multiple API endpoints.


● Integrate a middleware function to log the response time of each request.
● Implement a mechanism to generate an alert (e.g., log a warning message) if the
response time exceeds a predefined threshold (e.g., 200ms).
● Provide a way to aggregate the response time logs and generate a simple report
showing the average response time for each endpoint.

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.

You might also like