Posts

Showing posts with the label system

System Architecture Design

Image
Introduction The System Architecture Design process is a series of engineering activities aimed at transforming business requirements into a complete, optimized and scalable infrastructure and software model. The process of system architecture design steps includes: Requirement Analysis & Scope Definition This is the time for Technical Requirement Gathering & Analysis to clarify two core groups of requirements with Stakeholders and Product Team : Functional Requirements (FR) : What the system can do (such as ordering, payment, sending notifications, etc.). Non-Functional Requirements (NFR) : How the system operates (such as latency < 100ms, target QPS/RPS, 99.99% availability, OWASP/GDPR security standards, Cloud budget). Capacity Estimation & Resource Planning Preliminary calculation of operational metrics based on expected active users such as DAU (Daily Active Users) or MAU (Monthly Active Users) Traffic Estimation : Calculate average and peak reques...

Caching strategies

Image
Introduction In this article, we will learn about popular Caching strategies used today. It should be noted that applying cache is inherently a trade-off, it helps improve system performance but increases complexity, while also requiring acceptance that data retrieved by users might not be the latest. When using cache, you need to answer the question of which entity will be responsible for writing to the cache and when to write it. Below are popular Cache Patterns . CACHE-ASIDE (LAZY LOADING) The app manages the cache itself, reading from cache first and upon a cache miss, it queries the Database and then writes back to the cache. This is the most popular type and even if the cache fails, the app remains functional. For each cache miss, it always takes 3 processing steps including Reading cache -> Querying Database -> Writing cache. The first read is always slow (cold start) because there is no cache initially. Used when reading frequently, writing rarely and ac...

Using Clause (Part 2)

Image
Introduction Besides the clauses mentioned in the previous article, PostgreSQL, as an exceptionally powerful database management system, supports many other specialized clauses as follows. Navigation and Pagination Group This is a basic yet crucial group that is very widely used. ORDER BY : Sorts the returned results in ascending ( ASC ) or descending ( DESC ) order. There is also ORDER BY col DESC NULLS LAST to push NULL values to the very bottom of the result table instead of the default top when sorting in descending order. LIMIT/OFFSET : Used for pagination. LIMIT N retrieves a maximum of N rows. OFFSET M skips the first M rows before retrieving. When you use OFFSET M , PostgreSQL must still scan and count all the first M rows to know where to begin, then it retrieves the next N rows for LIMIT . The consequence is that if OFFSET is small (for the first pages), the query still runs very fast. If OFFSET is large, such as using OFFSET 100000 , the database must expend resour...