Posts

IMAP protocol summary

Image
IMAP - internet message access protocol. Versions : IMAP1 (Interim Mail Access Protocol) - 1986. IMAP2 (Interactive Mail Access Protocol) - 1988. IMAP3 - 1991. IMAP4 - 1994, last updates - 2003. IMAP is used to read emails that came to the user's mailbox. Emails are stored on server :  Clients connect to the server and download emails only after a user request.  The server can perform complex operations with emails. Advantages : Several clients can work at the same time. All clients see the same mailbox status. Disadvantages :  Protocol is more complex in comparison to POP3. Server space for the mailbox is usually limited. IMAP is an application layer protocol and uses the TCP transport layer protocol. Port 143. IMAP allows you to use multiple mailboxes or folders: Folders are stored on server. Folders can form a hierarchy. Emails can be moved from one folder to another. Flag : It's an email "label". Emails can have one or multiple flags. System flags: \Seen \Answe...

POP3 protocol summary

Image
POP - post office protocol. Versions: POP1 - 1984 POP2 - 1985 POP3 - 1988 Updated version of POP3 with additional authentication mechanisms and extensions - 1996 POP3 communication schema The approach "download and delete": The message storage on the server is a temporary storage for messages. All messages must be transferred to the mail client. After uploading to the client, the messages are deleted from the server. Advantages: Simple protocol. Letters are available when there is no network connection. Disadvantages: Only 1 client. Single mail storage (no folders, filters, flags, etc.). POP3 is an application layer protocol (port 110), it uses TCP transport protocol. Session states: Authorization - the client introduces himself and confirms that he is who he says he is. Transaction - the client downloads the mail and marks the downloaded message for deletion. Update - the server deletes the marked message and closes the connection. POP3 works in text mode, interacting in a ...

SMTP protocol summary

Image
SMTP - simple mail transfer protocol. Created in 1982 with further modernization in 2008 (ESMTP). A protocol is used for mail transmission and can work with any transport protocol (TCP, UDP). General mail exchange idea Ports : 25 - mail transmission between servers (mail transfer agent) 587 - mail transmission from client On practice port 25 is used.   Email format :   Envelope (SMTP commands)           Header (RFC 2822)         Body (RFC 2822) SMTP works in text format (request - response interaction). Commands : SMTP responses:   Letter headers: Extended SMTP (ESMTP) commands: EHLO - extended HELO STARTTLS - to use encryption SIZE - max allowed letter size DSN - letter delivery confirmation Security and spam: SMTP does not contain data protection mechanisms. The contents of MAIL FROM and FROM are not controlled in any way Data is transmitted over the network in open form (except using STARTTLS) Spam defe...

System design tips on how to make capacity estimation

Image
Estimation is an important skill in system design interviews because it allows you to demonstrate your ability to reason about the complexity and feasibility of a given problem. It is worth noting that estimation is an inexact science and that it is normal for estimates to be off by some margin. It is more important to show that you have a clear understanding of the problem and can provide a thoughtful and well-reasoned estimate than to provide a perfectly accurate one. Here are a few examples of the types of estimation questions you might encounter in a system design interview: How many users can a system support? For example, you might be asked to estimate the number of users that a social media platform can support, based on the number of servers, storage, and bandwidth available. How much data can a system store or process? For example, you might be asked to estimate the amount of data that a data warehouse can store, based on the size of the data, the number of serv...

Cheat sheet on how to choose database

Image
The effectiveness and scalability of your design depends greatly on the choice of database. It is possible to use multiple databases within a single system for different purposes.   DB cheet sheet (you can click on image to expand it) Caching solutions such as Redis and Memcached are key-value storage systems that can be used to improve the performance of a system by temporarily storing frequently accessed data in memory.   For storing large files such as images and videos, it is often useful to use a file storage service such as S3 or Google Cloud Storage . These are known as blob storage systems and can be used in conjunction with a content delivery network (CDN) to improve the performance and reliability of file access. To support full text search you could to use Elastic search or Solar . To support monitoring system InfluxDB or Prometheus may be good options to consider. For analytics on extremely large datasets and where transactions are not a requirement,...

10 tips when you decide to use kafka

Image
Overall, Kafka is a powerful and flexible tool that is well-suited for handling large volumes of data in real-time. Here are ten best practices when you decide to use it: To ensure high availability and handle high load, it is important to set up a cluster of servers when using Kafka, as it is designed to scale horizontally across multiple machines. Use a message retention period: Kafka allows you to specify a message retention period, which determines how long messages are kept before they are deleted. It is important to set this value appropriately to ensure that you have enough data for processing, but not so much that you run out of storage space. Use message compression: Kafka supports message compression to reduce the amount of data that needs to be transferred and stored. This can be particularly useful when sending large messages or when dealing with high volumes of data. By setting a key on each message, you can specify which partition the message should be written to in Ka...

How to design notifications service system

Image
This post is a personal cheat sheet on how to design notifications service system. Usually it’s embedded system. Questions to ask: What types of notifications are we allowed to send? Should it be plugable (it’s easy to add new type of notification)? Should we build system as SaaS product or this system is only for internal usage? Do we need to implement notifications prioritization (multiple notifications are sent at the same time)? What’s expected system load? Functional requirements: Send notifications To be plugable (easy to add new type of notifications) To provide saas service (you also should be able to rate limit, user should not be able to get more than 5 promotional notifications per day) To prioritize notifications (process high priority messages first, for example password notifications) Non-functional requirements: High availability High load Design overview: Actually in case if system is small and expects low load all services can be wrapped into one monolith. But it’s not...