Last updated on

Application Architecture

šŸ’» Application Architecture: A Developer’s Perspective

Code Deployment and the Server

The starting point for a developer is writing code, which must be built and deployed.

  • Build and Deploy: The code is processed—often on a CI/CD server (Continuous Integration/Continuous Deployment) in a professional environment—before it reaches its final running location.
  • Server: The destination where the code runs. A server is essentially a computer that handles requests and serves users.

Data Storage

A production application requires a mechanism to store data persistently.

  • Persistent Storage: This is an external storage mechanism that is not running on the main server. While it could be a database, the term is open-ended, covering many ways to store information.
  • Distributed Nature: This storage is connected to the server over a network and could even be located in different parts of the world, distinguishing it from the server’s local disk.

Handling User Requests

External users interact with the application by sending requests to the server, typically from their browser.

  • Front-end Serving: The server might respond with JavaScript/HTML code for the user’s browser to load a page.
  • Back-end API: The server could be a back-end, and the user’s browser makes requests to its API, which responds with data, often in a format like JSON.

Scaling the Application

When a single server can’t handle a high volume of concurrent user requests, scaling techniques are used to improve capacity.

Vertical Scaling (Scaling Up)

  • This involves taking a single resource (like a server) and making it better by upgrading its hardware, such as its CPU, RAM, or disk.
  • This is conceptually simple but has limitations because computer hardware has a finite capacity.

Horizontal Scaling (Scaling Out)

  • This involves creating multiple copies of the server, each running the same code.
  • The benefit is that multiple users can talk to different servers, increasing the ability to handle more requests simultaneously.

Load Distribution and External Services

With multiple servers, a mechanism is needed to efficiently manage incoming traffic.

  • Load Balancer: This component sits in front of the multiple servers and forwards incoming requests to the server with the minimal traffic, ensuring a balanced workload.
  • External Server Communication: The application’s servers may also communicate with other external APIs (e.g., a payment API like Stripe) to perform specific tasks.

šŸ› ļø Developer Operations and Monitoring

Developers have additional responsibilities to monitor the application’s health and performance.

Logging

  • Logging Service: An external service where the server records information (logs) about every request (success or failure).
  • Developer Interaction: Developers interact with this service to gain insight into the server’s operation and diagnose issues.

Metrics and Alerting

  • Metric Service: This provides data (metrics) about the server’s resource usage (CPU, RAM, storage) and application performance (request success/failure rates).
  • Log-Based Metrics: Some metrics are derived from the timestamps and content of the logs.
  • Alerting Service: This service processes metrics and automatically notifies developers (a push notification) when a metric reaches a defined threshold (e.g., success rate dips below 95%). This ensures immediate awareness of problems.

🌐 The Role of Networking

An essential underlying concept, even for a simplified architecture, is networking.

  • Inter-Component Communication: Since components like the server, persistent storage, and logging service are often running on different computers, networking is what allows them to communicate with each other. Understanding networking basics is crucial for designing large-scale applications.