Key System Design Concepts
In this article, we are going to learn several systems design concepts that you should understand to improve your skills from junior developer to higher degrees. You can use these concepts to build scalable applications, prepare for your next job interview or simply increase your value.
Vertical Scaling
Imagine a single server hosting a website for food delivery service. At peak times in the afternoon, your website experiences a high volume of traffic. To prevent your server of crashing during these peak times, you could „scale up“ your system with additional resources like RAM, CPU or storage. This is called „vertical scaling“ — upgrading your server or switching to a new server with better features. But this approach is limited and is a high risk of a single point of failure that crashed your website.
Horizontal Scaling
The other way to keep your website from failing is „horizontal scaling“. Instead of adding extra resources to a server, which is limited, you can add additional infrastructure to your system, such as servers, to split up the huge traffic during peak times. This approach is quite unlimited, you don’t even need powerful servers and if one of our servers goes down all of the other servers can continue to fulfill requests. You can imagine a row of servers side by side that look like a horizon, which gave this type of scaling its name.
Load Balancer
To ensure that one server won’t get overloaded while the other are sleeping, we can use the next system calls „load balancer“, which divided the upcoming traffic into serval servers. It’s also known as reverse proxy, that redirects incoming requests in combination with algorithms to appropriate server. There are to different kinds of load balancer, the first one is a 4 and 7 layer category. The 4 layer one is working with the network and transport layer protocols IP, TCP, FTP & UDP, meanwhile the 7 layer is reading the protocol of the HTTP request. The algorithm round robin for example balance the traffic with cycling through the pool of servers. Other examples are hashing the request ID, weighted round robin or least connection.
Content Delivery Networks (CDN)
Now we’re able to to split the traffic amount of near located server, which brings us to the world wide use of server: the CDN (content delivery/distribution network). When a user is far away from servers, it will take a long time to load files like videos or website covers. With CDN server, you store static website content geographically close to users and it can load faster. So CDNs have no real application logic, they just take the files from the origin/host server and copy them on the the CDN servers using push or pull fundamentals.
Caching
CDN are a technique for creating copies of data near your location. Caching is a high-speed storage layer that temporarily stores partial data so that future requests can be served faster. With caching you can efficiently reuse data that you have already used or calculated. The computer stores this copied data in memory in our L1, L2 or L3 CPU cache. An example for a cache system is a DNS cache server that stores domain requests to resolve the domain names with the IP addresses.
TPC / IP / UDP
IP addresses are necessary for each connection between computers, each individual device is assigned a unique identifier. The TCP/IP stands for the Transmission Control Protocol/Internet Protocol and describes a suit for communication protocols that enable data to be routed to the correct recipient via the internet. It is also used for private computers such as intranets or extranets. In short, it’s like the postal service that works with rules to divide the data in packages, address them and transport them to the right recipient. Within this TCP/IP protocol, there is the TCP and the User Datagram Protocol (UDP) that works over the IP. The difference between the two is the workflow of data transmission, for example, TCP numbers each package to ensure the memory of the order and also uses a mechanism to prevent the loss of packages, sending a confirmation of receipt all parts back to the sender. Another point is error checking of the data. Whether data is corrupted or lost TCP resend the packages. UDP, on the other hand, simply sends the data without any checkings.
Domain Name System (DNS)
How we ensure that we’re addressing the correct destination? This is done using a hierarchal naming system, the Domain Name System (DNS), which uses IP networks to answer requests of domain names. Its similar to a phone book, you type the domain medium.org into the search bar and the DNS changes that domain to an IPv4 or IPv6 address like 192.186.2.1 or 2001:db6:85a1:8d4:1329:8a2e:370:7347, to direct you to the correct endpoint.
HTTP(S)
To encrypted the communication between the client and server is the Hypertext Transfer Protocol/ Secure (HTTP/S) used. That ensures that no third party intercepts the communication by reading the WLAN network traffic. Additionally, the web server is authorized at the beginning of the connection by a certificate that is sent to the client to prove the trustworthiness of the domain. The „S“ in HTTPS stands for the secure aspect, meaning that HTTP and HTTPS are completely the same except for the SSL/TLS transport protocol used by HTTPS to secure the transmission method.
REST API
One of the most common types of application program interface (API) uses the HTTP protocol to transfer data between web-based applications, the Representational State Transfer API (REST API or RESTful API). While outdated protocols such as SOAP (Simple Object Access Protocol), which use unwieldy formats like XML or settings, adhere to strict rules for interaction. The REST-API uses the common JSON (JavaScript Object Notation) to provide flexibility, speed and simplicity to receive data over the internet. The client starts the process with a request using the HTTP commands. For example, you can use „GET + URL“ to retrieve a particular resource. Alternative commands are POST (create a new resource), PUT (update a resource) or DELETE (delete a resource). The client responds with various resources such as data, images, videos, web addresses, comments or tweets. The response is mostly delivered in JSON format. Which is readable by human and machines. Compatibility with many programming languages makes the REST API suitable for various applications.
Conclusion
In this first part of „key system design concepts“ we covered the most commonly used technologies to create a secure, fast and simple website or web application. The second part will cover basic theories and alternatives to the REST-API with HTTP. For example Graph QL, gRPC and WebSockets.
Have fun learning!
Thank you for reading my article. I really appreciate every kind of response. For more information about me: https://www.linkedin.com/in/danielovtchinnikov/