Proxies
What are proxies and the difference between forward and reverse proxies. Plus the most important definitions to know about graphs.
Hi Friends,
Welcome to the 12th issue of the Polymathic Engineer newsletter.
Today we will talk about:
What are proxies
The difference between forward and reverse proxies
what are the main definitions to know about graphs
coding challenge
two interesting tweets
Proxies
Proxies are a fundamental component of almost every distributed system. According to its definition, a proxy is a server acting as an intermediary between a set of clients and a set of servers.
There are many types of proxies, but all of them belong to 2 categories: forward and reverse.
Forward proxies
A forward proxy is a server configured to act on behalf of a client. The client's requests go to the proxy instead of the server. The proxy forwards the requests to the server and waits for responses sending them back to the client.
In this way, the server doesn't know who the client is. It only knows the source IP address of the proxy. So a forward proxy can secure and hide the identity of the client. VPNs work according to the same principle.
Using a forward proxy, clients can access servers they wouldn't be supposed to access. But using forward proxies also has advantages at the system level since they can:
• selectively send/block requests
• log or monitor requests
• cache responses
Reverse proxies
A reverse proxy is a server configured to act on behalf of another server. The proxy receives the client's requests instead of the server. The proxy forwards the requests to the server and waits for responses sending them back to the client.
The client has no idea that it is communicating with the reverse proxy. The responses are returned to the client, appearing to originate from the server itself. So a reverse proxy can secure and hide the identity of the server.
The main advantages of using reverse proxies are:
• Load balancing among a group of servers
• Anonymity and increased security for the servers
• Better performances, executing additional tasks in place of the servers
For example, reverse proxies can cache static content reducing the overall system latency. Or they can take the load off of the servers performing additional tasks like:
• Data compression and decompression
• Data encryption and decryption
• HTTP authentication
Introducing reverse proxies in a system also has disadvantages:
• the system complexity increases
• reverse proxies redundancy is necessary to avoid single points of failure
As usual, using a reverse proxy layer in a system, it's a matter of trade-offs.
Additional resources
If you want more details about proxies, you can check out this article I posted on my personal website.
Graph definitions
Graphs are a very flexible data structure. The only one that can capture any real-world data and model any relationship.
Here the basic glossary with all the definitions that a developer should know about graphs.
Node (or vertex): a single unit of data
Edge: a connection between 2 nodes
Order: number of nodes in the graph
Size: number of edges in the graph
Node degree: number of edges incident to the node
Isolated node: a node not connected to any other node in the graph (with 0 degree)
Adjacent nodes: 2 nodes connected by an edge
Self-loop: an edge from a vertex to itself
Multi-edge: an edge occurring multiple times
Directed graph: a graph where all the edges have a direction from one node to another
Undirected graph: a graph where all edges have no direction
Weighted graph: a graph where each edge has assigned a numerical value or weight
Unweighted graph: a graph where all edges have no weights
Sparse graph: a graph where only a tiny fraction of the possible node pairs are connected
Dense graph: a graph where a significant fraction of the vertex pairs are connected
Path: a sequence of edges and nodes from a source to a destination node
Path length: number of edges in a path
Cycle: a path where the source and destination nodes are the same
Connected graph: a graph where there is a path between any pair of nodes
Acyclic graph: a graph not containing any cycle between its nodes
Trees: connected, acyclic undirected graphs
Cyclic graph: a graph containing cycles between its vertices
DAG: a directed acyclic graph. Helpful to model data with precedence constraints
Bipartite graph: a graph where nodes can be marked using 2 colours so that no adjacent nodes have the same colour
Coding challenge
The coding challenge from last week was Valid Parenthesis. The problem asks to process a string of parentheses and check that they match in the correct order. The nature of the problem bring to process characters in LIFO order.
If the current character is a closed brackets it should match with the last inserted open brackets. Using a stack to process the data in the input string comes natural for this problem.
Instead of hardcoding brackets into the code, a more elegant solution is to encode the correspondences between open and closed bracket into a dictionary.
The time complexity of this solution is O(N) time and O(N) space.
The coding challenge for the next week is Implement Queue using Stacks.
Interesting Tweets
Idempotency means that the effect of a successful request on a server resource is independent of the number of times it is executed. This tweet provides a good mental map of all the considerations necessary to implement idempotent APIs.


The more you work in the software industry, the more you realize that knowing everything is impossible. And that soft skills are at least as relevant as technical ones.

Everyone can become a developer without a CS degree. But in my opinion, a CS degree is still the most comfortable path to become a developer.