Lợi Lê retweeted
Quantum software is essential to make quantum technology work. The #QuantumSoftwareAlliance is a network of research institutions focused on making quantum computing practical through software, with an emphasis on co-design, algorithm discovery, verification, benchmarking, and interoperability.
The web page is now up and alive and has been announced today during the last event of the @QuantumYear2025.
quantumsoftwarealliance.org
We at @FU_Berlin are happy to have contributed to this effort.
Lợi Lê retweeted
How to scale a website to support millions of users? We will explain this step-by-step.
The diagram below illustrates the evolution of a simplified eCommerce website. It goes from a monolithic design on one single server, to a service-oriented/microservice architecture.
Suppose we have two services: inventory service (handles product descriptions and inventory management) and user service (handles user information, registration, login, etc.).
Step 1 - With the growth of the user base, one single application server cannot handle the traffic anymore. We put the application server and the database server into two separate servers.
Step 2 - The business continues to grow, and a single application server is no longer enough. So we deploy a cluster of application servers.
Step 3 - Now the incoming requests have to be routed to multiple application servers, how can we ensure each application server gets an even load? The load balancer handles this nicely.
Step 4 - With the business continuing to grow, the database might become the bottleneck. To mitigate this, we separate reads and writes in a way that frequent read queries go to read replicas. With this setup, the throughput for the database writes can be greatly increased.
Step 5 - Suppose the business continues to grow. One single database cannot handle the load on both the inventory table and user table. We have a few options:
1. Vertical partition. Adding more power (CPU, RAM, etc.) to the database server. It has a hard limit.
2. Horizontal partition by adding more database servers.
3. Adding a caching layer to offload read requests.
Step 6 - Now we can modularize the functions into different services. The architecture becomes service-oriented / microservice.
Question: what else do we need to support an e-commerce website at Amazon’s scale?
--
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/bbg-social
Lợi Lê retweeted
Why is single-threaded 𝐑𝐞𝐝𝐢𝐬 so 𝐟𝐚𝐬𝐭?
There are 3 main reasons as shown in the diagram below.
1. Redis is a RAM-based database. RAM access is at least 1,000 times faster than random disk access.
2. Redis leverages IO multiplexing and single-threaded execution loop for execution efficiency.
3. Redis leverages several efficient lower-level data structures.
Question: Another popular in-memory store is Memcached. Do you know the differences between Redis and Memcached?
--
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/bbg-social
Lợi Lê retweeted
HTTP 1.0 -> HTTP 1.1 -> HTTP 2.0 -> HTTP 3.0 (QUIC).
What problem does each generation of HTTP solve?
The diagram below illustrates the key features.
🔹HTTP 1.0 was finalized and fully documented in 1996. Every request to the same server requires a separate TCP connection.
🔹HTTP 1.1 was published in 1997. A TCP connection can be left open for reuse (persistent connection), but it doesn’t solve the HOL (head-of-line) blocking issue.
HOL blocking - when the number of allowed parallel requests in the browser is used up, subsequent requests need to wait for the former ones to complete.
🔹HTTP 2.0 was published in 2015. It addresses HOL issue through request multiplexing, which eliminates HOL blocking at the application layer, but HOL still exists at the transport (TCP) layer.
As you can see in the diagram, HTTP 2.0 introduced the concept of HTTP “streams”: an abstraction that allows multiplexing different HTTP exchanges onto the same TCP connection. Each stream doesn’t need to be sent in order.
🔹HTTP 3.0 first draft was published in 2020. It is the proposed successor to HTTP 2.0. It uses QUIC instead of TCP for the underlying transport protocol, thus removing HOL blocking in the transport layer.
QUIC is based on UDP. It introduces streams as first-class citizens at the transport layer. QUIC streams share the same QUIC connection, so no additional handshakes and slow starts are required to create new ones, but QUIC streams are delivered independently such that in most cases packet loss affecting one stream doesn't affect others.
Question: When shall we upgrade to HTTP 3.0? Any pros & cons you can think of?
--
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/bbg-social
Lợi Lê retweeted
Top Eventual Consistency Patterns You Must Know
Eventual consistency is a data consistency model that ensures that updates to a distributed database are eventually reflected across all nodes. Techniques like async replication help achieve eventual consistency.
However, eventual consistency can also result in data inconsistency. Here are 4 patterns that can help you design applications.
Pattern#1 - Event-based Eventual Consistency
Services emit events and other services listen to these events to update their database instances. This makes services loosely coupled but delays data consistency.
Pattern#2 - Background Sync Eventual Consistency
In this pattern, a background job makes the data across databases consistent. It results in slower eventual consistency since the background job runs on a specific schedule.
Pattern#3 - Saga-based Eventual Consistency
Saga is a sequence of local transactions where each transaction updates data with a single service. It is used to manage long-lived transactions that are eventually consistent.
Pattern#4 - CQRS-based Eventual Consistency
Separate read and write operations into different databases that are eventually consistent. Read and write models can be optimized for specific requirements.
Over to you: Which other eventual consistency patterns have you seen?
--
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/bbg-social
#systemdesign #coding #interviewtips
.
Lợi Lê retweeted
How do microservices collaborate and interact with each other?
There are two ways: 𝐨𝐫𝐜𝐡𝐞𝐬𝐭𝐫𝐚𝐭𝐢𝐨𝐧 and 𝐜𝐡𝐨𝐫𝐞𝐨𝐠𝐫𝐚𝐩𝐡𝐲.
The diagram below illustrates the collaboration of microservices.
--
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/bbg-social
Lợi Lê retweeted
How do we design secure and safe APIs?
The rise in API-related security breaches highlights the necessity for robust API security.
Let's look at 12 essential tips for improving API security:
🔹 HTTPS
Enforcing HTTPS for all API connections is a critical step in securing sensitive data since it ensures data encryption in transit, preventing attacks and interceptions.
🔹 Rate limiting and throttling
Throttling and rate limiting are vital for reducing API abuse and protecting against DDoS attacks as they manage request rates, which keeps our API available for legitimate users.
🔹 Authentication
Authentication is another must-have. Leverage strong authentication mechanisms, such as OAuth, to verify user or system identities.
Learn more about API authentication here: drp.li/api-authentication-z7…
🔹 Authorization
After authentication comes authorization. Follow the least privilege principle to ensure users access only role-relevant data and actions, reducing unauthorized access risks.
🔹 Input validation
Validating API inputs is crucial to safeguard against vulnerabilities like SQL injection and XSS. Whitelisting can also be useful here to ensure only valid data is processed.
🔹 API gateway
Deploy an API Gateway as a security layer, managing authentication, monitoring traffic, and enforcing policies like rate limits.
🔹 Regular security audits
Regular security audits and penetration testing are advisable to identify and fix vulnerabilities, preventing exploitation and maintaining API security.
🔹Dependency management
Regularly updating software dependencies is important to mitigate risks from vulnerabilities in external libraries.
🔹 Logging and monitoring
Investing in comprehensive logging and real-time monitoring is vital for early detection of suspicious activities, enabling swift incident response to mitigate security breaches.
🔹API versioning
To manage changes and updates securely, utilize proper API versioning, which prevents compatibility and security issues.
Learn more about API versioning here: drp.li/api-versioning-postma…
🔹Data encryption at rest
Encrypting sensitive data at rest is crucial to prevent unauthorized access and comply with data protection regulations.
API security isn’t a nice to have; it’s a must. Following the techniques and best practices I’ve shared above will take you a long way, they are the foundations of building safe and secure APIs.
A great way to automate checking the health, security, and performance of your APIs is Postman Monitors.
You can learn more about it here: drp.li/postman-monitors-z7ld
Lợi Lê retweeted
What are the top 𝐜𝐚𝐜𝐡𝐞 strategies?
Read data from the system:
🔹 Cache aside
🔹 Read through
Write data to the system:
🔹 Write around
🔹 Write back
🔹 Write through
The diagram below illustrates how those 5 strategies work. Some of the caching strategies can be used together.
I left out a lot of details as that will make the post very long. Feel free to leave a comment so we can learn from each other.
Question: What are the pros and cons of each caching strategy? How to choose the right one to use?
--
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/3KCnWXq
Lợi Lê retweeted
The best performance improvements also save money.
Here, you can learn how to use a Search Index to save money and improve your system.
We struggled to run a query in the Database (like every big system). We have a big VM hosting a massive database with mostly all the data we need.
One of the products we host is a directory of people you can hire; you can search by:
• Name
• State
• Skills
• Many other fields
We have some problems there:
• When you search by name, people misspell words all the time, so we have to use the “LIKE” statement, and with millions of records, the performance was taken a hit.
• Skills was a separate table, and you could choose multiple skills to search, which means expensive JOINs.
• We paid a lot to vertically-scale the DB to hold the heavy load.
The solution was a new index, but not a database index; we used Azure AI Search.
Azure AI Search provides advanced search capabilities and is particularly good at handling large datasets and complex queries.
How we did it:
1. We created a JSON representation of the information we want to save to the index. It is simple: you make your classes and save them to the index like a JSON document.
2. Every time the information changes, we send a message to a Queue
3. An Azure function reacts to the message and refreshes the information in the index
4. Our API search endpoint translates the request coming from the UI and queries the index.
What benefits we got:
• We could downscale the DB; this is how we saved hundreds of dollars monthly.
• The new service was a fraction of that saving, so we put money back into our pocket.
• We avoid scaling our DB horizontally (trust me, this is complex)
• Azure AI Search often follows a pay-as-you-go model, meaning you only pay for what you use.
• Our search is 10x faster now.
• Supports complex queries, fuzzy searches, and auto-completion.
• Offers AI-driven capabilities like semantic search
Don’t leave performance and cash on the table!
Lợi Lê retweeted
Top 9 Architectural Patterns for Data and Communication Flow
🔹 Peer-to-Peer
The Peer-to-Peer pattern involves direct communication between two components without the need for a central coordinator.
🔹 API Gateway
An API Gateway acts as a single entry point for all client requests to the backend services of an application.
🔹 Pub-Sub
The Pub-Sub pattern decouples the producers of messages (publishers) from the consumers of messages (subscribers) through a message broker.
🔹 Request-Response
This is one of the most fundamental integration patterns, where a client sends a request to a server and waits for a response.
🔹 Event Sourcing
Event Sourcing involves storing the state changes of an application as a sequence of events.
🔹 ETL
ETL is a data integration pattern used to gather data from multiple sources, transform it into a structured format, and load it into a destination database.
🔹 Batching
Batching involves accumulating data over a period or until a certain threshold is met before processing it as a single group.
🔹 Streaming Processing
Streaming Processing allows for the continuous ingestion, processing, and analysis of data streams in real-time.
🔹 Orchestration
Orchestration involves a central coordinator (an orchestrator) managing the interactions between distributed components or services to achieve a workflow or business process.
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/3KCnWXq
Lợi Lê retweeted
LeetCode was HARD until I Learned these 15 Patterns:
1. Prefix Sum
2. Two Pointers
3. Sliding Window
4. Fast & Slow Pointers
5. LinkedList In-place Reversal
6. Monotonic Stack
7. Top ‘K’ Elements
8. Overlapping Intervals
9. Modified Binary Search
10. Binary Tree Traversal
11. Depth-First Search (DFS)
12. Breadth-First Search (BFS)
13. Matrix Traversal
14. Backtracking
15. Dynamic Programming Patterns
I wrote a detailed article on these patterns and provide links to leetcode problems you can practice to learn them better.
Check it out here: blog.algomaster.io/p/15-leet…
Subscribe for more such articles every week.
Lợi Lê retweeted
10 Good Coding Practices
1. Follow code specifications (e.g., "PEP 8", "Google Java Style") for consistent and readable code.
2. Document and comment code clearly and concisely, focusing on "Why" rather than "What".
3. Write robust code that handles unexpected situations and inputs without crashing.
4. Follow the SOLID principles for scalable and maintainable code.
5. Make testing easy by reducing complexity and supporting automated testing.
6. Use abstraction to extract core logic and hide complexity, making code flexible and generic.
7. Utilize design patterns appropriately, avoiding overuse or misuse.
8. Reduce global dependencies; rely on localized state and parameter passing.
9. Continuously refactor code to reduce technical debt and maintain extensibility.
10. Prioritize security to avoid vulnerabilities like SQL injection and XSS.
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/496keA7
























