What Are Some Key Concepts That Every Backend Engineer Should Know?

By Prajwal Haniya

Techletter #19 | April 20, 2023

As my interest in backend engineering has elevated, I am giving my spare time to enhance my understanding of this field. I do write a lot of code in both React and nodejs. So, I need to learn a lot of things every day in order to solve different kinds of problems that I come across.

Recently I have started watching a course by Hussain Nasser.

I have documented my short notes below. Hope you will pick up some wonderful concepts and satisfy your curiosity along he way.

Request Response

The request and response are the basic building blocks of communication between a client and a server. In the context of web development, the HTTP protocol is commonly used for exchanging requests and responses between clients and servers.

Client Sends a request -> Server parses the request -> Server Processes the request -> Server sends the response -> Client parses the response & consume.

This is just a short note. Will be explaining them in detail in the upcoming articles

Synchronous & Asynchronous I/O

Push

What is push?

Pros and cons of push

You can use web socket for this.

Polling

What is Short Polling?

Pros - Simple to build - Good for long running requests - Client can disconnect Cons - Too chatty - Network bandwidth - Wasted backend resources

Lets implement a short polling

const app = require('express')();

const jobs = {};

app.post('/submit', (req, res) => {
    const jobId = `job:${Date.now()}`
    jobs[jobId] = 0;
    updateJob(jobId, 0);
    res.end("\n\n" + jobId + "\n\n");
});

app.get('/checkstatus', (req, res) => {
    console.log(jobs[req.query.jobId])
    res.end("\n\nJobStatus:" + jobs[req.query.jobId] + "%\n\n")
});

app.listen(8080, () => console.log("Server is listening"));

const updateJob = (jobId, progress) => {
    jobs[jobId] = progress;
    console.log(`updated ${jobId} to ${Progress}`);
    of (progress === 100) return;
    this.setTimeout(() => updateJob(jobId, progress + 10), 3000);
} 

Long Polling

Pros - Less chatty & backend friendly - Client can still disconnect cons - Not real time

Wil be implementing the long polling in the upcoming articles.

Server Sent Events

Pros - Real time - Compatible with request/response Cons - Client must be online - Client might not be able to handle - Polling is preferred for light clients - HTTP/1.1 problem (6 connections)

Publish & Subscribe

── Video Upload/
    ├── Upload Service
    ├── Compress Service
    ├── Format Service
    ├── Notification Service
    └── Copyright Service

When you want to communicate between multiple services then req/res is not good.

Upload -> Upload service

Raw MP4 -> Compress Service -> Compressed video -> Format Service -> 480P, 720P, 1080P, 4K video -> Notification Service

Pros - Scales with multiple receivers - Great for microservices - Loose coupling - Works while clients not running

Cons - Message delivery issues - Complexity - Network saturation

Consider this as a simple list of concepts. There are many things which cannot be simply explained in one article. Hope, you have grasped few concepts, in turn you can question yourself and find answers which will staisfy your curosity.