Share The Backend Engineering Show with Hussein Nasser
Share to email
Share to Facebook
Share to X
By Hussein Nasser
4.9
3737 ratings
The podcast currently has 522 episodes available.
Fundamentals of Database Engineering udemy course https://databases.win
Fundamentals of Operating Systems Course
Fundamentals of Operating Systems Course
I am fascinated by how timeouts affect backend and frontend programming.
When a party is waiting on something you can place a timeout to break the wait. This is useful for freeing resources to more critical processes, detecting slow operations and even avoiding DOS attacks.
Contrary to common beliefs, timeouts are not exclusive to request processing, they can be applied to other parts of the frontend-backend communications. Let us explore this briefly.
0:00 Intro
2:30 Connection Timeout
5:00 Request Read timeout
10:00 Wait Timeout
12:00 Usage Timeout
14:00 Response Timeout
16:00 Canceling a request
19:50 Proxies and timeouts
Learn more about database and OS internals, check out my courses
Fundamentals of database engineering https://databases.win
Fundamentals of operating systems https://oscourse.win
This new PostgreSQL 17 feature is game changer.
You see, postgres like most databases work with fixed size pages. Pretty much everything is in this format, indexes, table data, etc. Those pages are 8K in size, each page will have the rows, or index tuples and a fixed header. The pages are just bytes in files and they are read and cached in the buffer pool.
To read page 0, for example, you would call read on offset 0 for 8192 bytes, To read page 1 that is another read system call from offset 8193 for 8192, page 7 is offset 57,345 for 8192 and so on.
If table is 100 pages stored a file, to do a full table scan, we would be making 100 system calls, each system call had an overhead (I talk about all of that in my OS course).
The enhancement in Postgres 17 is to combine I/Os you can specify how much IO to combine, so technically while possible you can scan that entire table in one system call doesn’t mean its always a good idea of course and Ill talk about that.
This also seems to included a vectorized I/O, with preadv system call which takes an array of offsets and lengths for random reads.
The challenge will become how to not read too much, say I’m doing a seq scan to find something, I read page 0 and found it and quit I don’t need to read any more pages. With this feature I might read 10 pages in one I/O and pull all its content, put in shared buffers only to find my result in the first page (essentially wasting disk bandwidth, memory etc)
It is going to be interesting to balance this out.
Fundamentals of Operating Systems Course
In this episode of the backend engineering show I describe an interesting bug I ran into where the web server ran out of ephemeral ports causing the system to halt.
0:00 Intro
0:30 System architecture
2:20 The behavior of the bug
4:00 Backend Troubleshooting
7:00 The cause
15:30 Ephemeral ports on loopback
Fundamentals of Operating Systems Course
Fundamentals of Operating Systems Course
https://oscourse.win
Allegro improved their Kafka produce tail latency by over 80% when they switched from ext4 to xfs. What I enjoyed most about this article is the detailed analysis and tweaking the team made to ext4 before considering switching to xfs. This is a classic case of how a good tech blog looks like in my opinion.
0:00 Intro
0:30 Summary
2:35 How Kafka Works?
5:00 Producers Writes are Slow
7:10 Tracing Kafka Protocol
12:00 Tracing Kernel System Calls
16:00 Journaled File Systems
21:00 Improving ext4
26:00 Switching to XFS
Blog
https://blog.allegro.tech/2024/03/kafka-performance-analysis.html
The podcast currently has 522 episodes available.
259 Listeners
106 Listeners
580 Listeners
634 Listeners
975 Listeners
7,596 Listeners
176 Listeners
9,474 Listeners
60 Listeners
642 Listeners
7,176 Listeners
37 Listeners