How is data sent over the network? Why do we need so many layers in the OSI model?
The diagram below shows how data is encapsulated and de-encapsulated when transmitting over the network.
1/9
๐น Step 1: When Device A sends data to Device B over the network via the HTTP protocol, it is first added an HTTP header at the application layer.
2/9
๐น Step 2: Then a TCP or a UDP header is added to the data. It is encapsulated into TCP segments at the transport layer. The header contains the source port, destination port, and sequence number.
3/9
๐น Step 3: The segments are then encapsulated with an IP header at the network layer. The IP header contains the source/destination IP addresses.
4/9
๐น Step 4: The IP datagram is added a MAC header at the data link layer, with source/destination MAC addresses.
๐น Step 5: The encapsulated frames are sent to the physical layer and sent over the network in binary bits.
5/9
๐น Steps 6-10: When Device B receives the bits from the network, it performs the de-encapsulation process, which is a reverse processing of the encapsulation process. The headers are removed layer by layer, and eventually, Device B can read the data.
6/9
We need layers in the network model because each layer focuses on its own responsibilities. Each layer can rely on the headers for processing instructions and does not need to know the meaning of the data from the last layer.
7/9
๐ Over to you: Do you know which layer is responsible for resending lost data?
8/9
Subscribe to our weekly newsletter to learn something new every week:
Code First v.s. API First - A change of software development philosophy.
The diagram below shows the differences between code-first development and API-first development. Why do we want to consider API first design?
1 of 10
๐นMicroservices increase system complexity
We have separate services to serve different functions of the system. While this kind of architecture facilitates decoupling and segregation of duty, we need to handle the various communications among services.
2 of 10
It is better to think through the system's complexity before writing the code and carefully defining the boundaries of the services.
/1 How do we ensure ๐๐จ๐ฆ๐ฉ๐๐ญ๐ข๐๐ข๐ฅ๐ข๐ญ๐ฒ when performing ๐๐๐ญ๐ ๐ฆ๐ข๐ ๐ซ๐๐ญ๐ข๐จ๐ง?
The diagram below shows how Apache Avro manages the schema evolution during data migration.
/2 Avro was started in 2009, initially as a subproject of Apache Hadoop to address Thriftโs limitation in Hadoop use cases. Avro is mainly used for two things: Data serialization and RPC.
/3 Key points in the diagram:
๐นWe can export the data to ๐จ๐๐ฃ๐๐๐ญ ๐๐จ๐ง๐ญ๐๐ข๐ง๐๐ซ ๐๐ข๐ฅ๐๐ฌ, where schema sits together with the data blocks. Avro ๐๐ฒ๐ง๐๐ฆ๐ข๐๐๐ฅ๐ฅ๐ฒ generates the schemas based on the columns, so if the schema is changed, a new schema is generated.
In this model, we deploy new changes to multiple services simultaneously. This approach is easy to implement. But since all the services are upgraded at the same time, it is hard to manage, test dependencies, and rollback.
With blue-green deployment, we have two identical environments: one is staging (blue) and the other is production (green). The staging environment is one version ahead of production.
/1 Have you heard of Domain-Driven Design (DDD), a major software design approach?
/2 DDD was introduced in Eric Evansโ classic book โDomain-Driven Design: Tackling Complexity in the Heart of Softwareโ. It explained a methodology to model a complex business. In this book, there is a lot of content, so I'll summarize the basics.
๐นEntity: a domain object that has ID and life cycle.
๐นValue Object: a domain object without ID.
๐นAggregate: a collection of Entities that are bounded together by Aggregate Root (which is also an entity).
RPC (Remote Procedure Call) is called โ๐ซ๐๐ฆ๐จ๐ญ๐โ because it enables communications between remote services when services are deployed to different servers. From the userโs point of view, it acts like a local function call
/2 The diagram below illustrates the overall data flow for ๐ ๐๐๐.
Step 1: A REST call is made from the client. The request body is usually in JSON format.
/3 Steps 2 - 4: The order service (gRPC client) receives the REST call, transforms it, and makes an RPC call to the payment service. gPRC encodes the ๐๐ฅ๐ข๐๐ง๐ญ ๐ฌ๐ญ๐ฎ๐ into a binary format and sends it to the low-level transport layer.