Posts

Showing posts with the label docker compose

Log Management for NestJS Servers with Grafana Loki

Image
Introduction Grafana: An open-source platform specialized in data visualization and monitoring. It connects to various data sources (like Prometheus, MySQL, ElasticSearch, and Loki) to create beautiful dashboards and set up automatic alerts. Grafana Loki: A log aggregation system designed by Grafana Labs. If Prometheus is the standard for metrics, Loki is "Prometheus for logs." Instead of indexing the entire log content, Loki only indexes metadata (labels), making it incredibly lightweight and resource-efficient. Why Use Grafana Loki for Log Management? Loki offers several major advantages over traditional solutions like the ELK Stack (Elasticsearch - Logstash - Kibana): Cost-Efficient Storage: Since it only indexes labels instead of full text, Loki’s index size is much smaller (often 10x smaller than Elasticsearch). You can store logs cheaply on services like AWS S3 or Google Cloud Storage. High Performance & Low Resource Usage: Loki doesn’t need massive CPU or RAM to ma...

Using Supavisor as a Connection Pool for PostgreSQL

Image
Introduction Connection Pool A Connection Pool is a mechanism to manage and reuse database connections. Without a connection pool, when an application sends a request to the database, it must undergo a successful TCP Handshake before executing the query and after receiving results, it must disconnect to release resources You can see the limitations of the traditional approach which is when there is a large volume of connections to the database, every request must experience all the steps mentioned above, greatly impacting system performance With a connection pool, right from startup, it pre-creates a fixed amount of connections to the database and keeps them alive, so when a request comes in, it only needs to take a connection from the pool and can use it immediately to execute the query and after completion, it just returns the connection to the pool for other applications to use instead of disconnecting Use cases Web/API applications with medium to large traffic: Any application serv...