Posts

PostgreSQL: A Comprehensive Guide to PostgreSQL Streaming Replication

Image
Introduction PostgreSQL, a powerful and open-source relational database management system, is renowned for its robustness, flexibility, and extensive feature set. According to DB-Engines , PostgreSQL is currently the fourth most popular database in the world and has risen quickly in recent years. It is also the second most popular open-source RDBMS, behind MySQL.  One of PostgreSQL's most valuable features is streaming replication, which provides high availability, fault tolerance, and load balancing by maintaining multiple copies of a database on different servers. In this post, we'll explore what PostgreSQL streaming replication is, how it works, and the steps to set it up with a hot standby and heartbeat monitoring.  What is PostgreSQL Streaming Replication? Streaming replication in PostgreSQL allows you to create a replica (or standby) server that continuously receives updates from a primary (or master) server. This replication method is asynchronous by default, but Postgr...

Rails: Create an API Wrapper of an External Service

  Introduction Have  you ever had the problem when you wanted to use an external API that didn’t have a ready-made library and you needed to write everything from scratch? You weren’t sure how everything should be split and separated in order to write readable and clear code? If you answered yes to any of these questions, this article is for you. I’ll show you how to write code that is responsible for connecting with the external API and how to split everything in order to write clear and maintainable code. It doesn’t matter if you use Rails or plain Ruby code, this code is flexible, so you can use it wherever you want. Let’s add a structure Your API wrappers should be kept in the app/apis folder. In the Rails application there is a folder for models, views, controllers – so why not add another one, for APIs? Let’s assume that there is no ready-made gem for Github API and we need to write their API wrapper. Start with creating a  github_api  folder in the  apis ...

Rails: Upgrading Ruby in Rails Applications a Comprehensive Guide

Why Upgrade Ruby? Ruby is continuously evolving, and with each new release, you gain performance improvements, security patches, and new features that can enhance your Rails application. Staying up-to-date with the latest Ruby versions also ensures better support from the Ruby and Rails communities, making it easier to maintain your application in the long run. Pre-Upgrade Checklist Before you start the upgrade process, it's essential to have a plan in place: Backup Your Application: Ensure you have a complete backup of your application, including the database and any important files. Test Suite: A comprehensive test suite is crucial. If you don’t have one, consider writing tests for the most critical parts of your application before proceeding. Understand Dependencies: Know which gems and libraries your application relies on, and check their compatibility with the new Ruby version. Review Release Notes: Go through the release notes of both Ruby and Rails to understand the chan...