Hussein Nasser (@hnasr) 's Twitter Profile
Hussein Nasser

@hnasr

Backend and Database Courses courses.husseinnasser.com YouTube youtube.com/@hnasr Author of pglocks.org Engineer @esri

ID: 170687510

linkhttps://node.win calendar_today25-07-2010 13:52:00

21,21K Tweet

76,76K Followers

648 Following

Hussein Nasser (@hnasr) 's Twitter Profile Photo

SQL update or delete statements are interesting. The row locks held by those queries in a transaction can cause blocking. In some systems (SQL Server) page locks can be taken instead, causing even more blocking. Switching the order of the statement so its closer to the

Hussein Nasser (@hnasr) 's Twitter Profile Photo

I enjoy reading public bug reports, especially if it relates to an error am looking up. some much good stuff, this one an h2 GO AWAY frame incompatible implementation between client and backend.

I enjoy reading public bug reports, especially if it relates to an error am looking up. 

some much good stuff, this one an h2 GO AWAY frame incompatible implementation between client and backend.
Hussein Nasser (@hnasr) 's Twitter Profile Photo

HTTP/1.1 protocol can mask inefficiently authored frontends. This is because of the browser connection pool limit (6-10 connections per domain) Once the backend advertises HTTP/2 or even 3, the floodgates opens and up to 200 requests can be sent concurrently. This can tax the

Hussein Nasser (@hnasr) 's Twitter Profile Photo

Microsoft IIS implementation of HTTP/2 is weird. Often when the backend accepts h2, it sends a SETTINGS frame telling the client the maximum number concurrent streams it supports. IIS doesn’t do that, which then Chrome interprets as the server supports unlimited concurrent

Hussein Nasser (@hnasr) 's Twitter Profile Photo

Sometimes you have to make pragmatic decisions to keep the software consistent and predictable. This one is an interesting discussion on an issue in curl project upon forcing reuse local address port reuse when the socket is in timewait state.

Sometimes you have to make pragmatic decisions to keep the software consistent and predictable. 

This one is an interesting discussion on an issue in curl project upon forcing reuse local address port reuse when the socket is in timewait state.
Hussein Nasser (@hnasr) 's Twitter Profile Photo

Whoever initiates TCP FIN leaves its socket in TIME_WAIT state for any pending packets to arrive from the remote. If you attempt reuse the same address/port the bind will fail. Unless the SO_REUSEADDR is set on the socket. curl doesn’t set SO_REUSEADDR by default, thus the

Whoever initiates TCP FIN leaves its socket in TIME_WAIT state for any pending packets to arrive from the remote. 

If you attempt reuse the same address/port the bind will fail. Unless the SO_REUSEADDR is set on the socket.

curl doesn’t set SO_REUSEADDR by default, thus the
Hussein Nasser (@hnasr) 's Twitter Profile Photo

Windows Kernel vs Linux Kernel when the port is unreachable (but the host is) Notice that Windows will return the failure in 2 seconds, while Linux returns immediately. This is exacerbated when you have both IP protocol families. You can use curl, telnet, ssh all have the same

Hussein Nasser (@hnasr) 's Twitter Profile Photo

Any code you write has a flaw, It might not be obvious today, but it will reveal itself one day. Google, Microsoft, Amazon and others all experienced severe outages during the pandemic. Because they didn’t anticipate the unique workload, they had to rewrite and redesign quite a

Hussein Nasser (@hnasr) 's Twitter Profile Photo

Lets talk about TCP blackhole, a fascinating network phenomenon. You see, IP fragmentation was created to allow large packets to pass through middle routers with smaller MTU (maximum transmission unit) than the sender. This quickly created performance and security problems

Hussein Nasser (@hnasr) 's Twitter Profile Photo

Building a correct and performant transactional system requires deep knowledge in database fundamentals, application context and workflows. First correctness: It is the skill to scope operations into atomic transactions while managing concurrency of those operations to ensure a

Hussein Nasser (@hnasr) 's Twitter Profile Photo

Operating systems (their kernel specifically) orchestrate many processes, allow access to memory, disk, network and execute processes by scheduling them to the CPU. Sounds simple when we put it this way but this task is vast. Writing efficient programs depends on how much

Operating systems (their kernel specifically) orchestrate many processes, allow access to memory, disk, network and execute processes by scheduling them to the CPU. Sounds simple when we put it this way but this task is vast. Writing efficient programs depends on how much
Hussein Nasser (@hnasr) 's Twitter Profile Photo

A request is like an arrow. its maximum speed is as it leaves the bow, then it slows down due to air and gravity. A request is at its maximum speed as it leaves the frontend’s NIC, then starts to slow down as it travels through network devices, proxies, the backend kernel, and

Hussein Nasser (@hnasr) 's Twitter Profile Photo

UDP is a message protocol, whatever the user writes is treated as a unit. Problem is we are restricted by data link transmission unit (called MTU). IP which carries UDP can be fragmented, to break that large message into smallest MTU. You can also disable fragmentation but

UDP is a message protocol, whatever the user writes is treated as a unit. 

Problem is we are restricted by data link transmission unit (called MTU). IP which carries UDP can be fragmented, to break that large message into smallest MTU. 

You can also disable fragmentation but
Hussein Nasser (@hnasr) 's Twitter Profile Photo

TCP blackhole is a network phenomenon where a TCP segment smaller than the MSS but larger than a router’s MTU is dropped and the sender is never notified because ICMP has been disabled. The handshake does through but subsequent larger segments (like TLS or HTTP requests) are

Hussein Nasser (@hnasr) 's Twitter Profile Photo

malloc takes size as input and returns a pointer to the start location of memory you requested (slightly more based on the os page size) free takes only a pointer and somehow it can tell exactly how much memory that pointer was allocated and free that much exactly. how? It

malloc takes size as input and returns a pointer to the start location of memory you requested (slightly more based on the os page size)

free takes only a pointer and somehow it can tell exactly how much memory that pointer was allocated and free that much exactly. how?

It
Hussein Nasser (@hnasr) 's Twitter Profile Photo

If you begin a Read Committed transaction (let’s call it tx1) and run a long-running SELECT statement — for example, one that performs sorts and joins on large datasets — the database takes a snapshot of the committed data at the moment the query begins. Shortly after this

Hussein Nasser (@hnasr) 's Twitter Profile Photo

To check row visibility, Postgres collects all active transactions into an array and rows are checked against that list. That becomes part of the snapshot for a transaction. If a row is created by any of those transactions it is not visible. That check can get expensive if

To check row visibility, Postgres collects all active transactions into an array and rows are checked against that list. That becomes part of the snapshot for a transaction. 

If a row is created by any of those transactions it is not visible.

That check can get expensive if
Hussein Nasser (@hnasr) 's Twitter Profile Photo

The backend TCP kernel receive queue controls how much data the frontend can send without waiting for an ACK. If the backend is busy and doesn’t call read() fast enough, the queue fills up. Less space means a smaller window, and the frontend backs off effectively slowing down