A hash is one of the data types in Redis. Redis hash is a map that that contains keys and their corresponding values. It is useful to store objects. Keys and values in Redis hash are string, but there are client libraries in Go to convert it to our type. In this article, I will show you how to use the hash data type in Redis.
[Read More]How to Use Single NGINX for Multiple Domains
Yesterday my friend ask me if a single NGINX can serve more than one domain name. Of course, it can! A singe NGINX instance can serve more than one domain name. It can also serve subdomains. It is useful if you use one server to serve multiple domain names, although it is not recommended.
[Read More]How to Use Redis in Golang
Many developers use Redis to cache data because it stores data in memory. It enables us to reduce load to our database or external service. Data stored in Redis have an expiration time, so Redis can release memory that is no longer used. This article will show you the basics of integrating Redis with Golang.
[Read More]How to proxy_pass in NGINX
NGINX is a web server that can be used as a reverse proxy. The request that is received by NGINX is sent to the proxied server, then the response is sent back to the client. To do reverse proxy, NGINX uses proxy_pass
directive inside a specified location
. This article will show you how.
SQL Query Timeout With Golang Context
One of Golang Context’s usage is to provide control over timeouts and cancelation. We can use this to control the timeout of SQL query execution and cancel it. This article will show you how to do that.
[Read More]Create Grafana Alert To Slack Channel
Slack is an application to send messages to your team. A Slack channel is one of the notification channels available in Grafana. You can use it to send an alert to a Slack channel when a metrics match with the alert rule. It is very beneficial to have alerts sent to slack, because you can spot problems immediately.
[Read More]Monitor Golang App With Prometheus and Grafana
As I have written before, monitoring your server’s metrics is important to maintain the reliability of your service. This article will show you the basics of monitoring your Golang application. The tools that we are going to use are Prometheus and Grafana.
[Read More]Monitor Server Metrics With Prometheus and Grafana
Monitoring your server’s metrics is important to maintain the reliability of your service. You can also save costs by downgrading your server if the average load is much lower than the maximum capacity of your server. There are many ways and tools to monitor your server. One of the most popular is by using Prometheus to scrape and store the metrics. And Grafana to visualize the data. This article will show you how to monitor your server’s metrics with Prometheus and Grafana, especially for Linux servers.
[Read More]Reduce Backend Load Using Cache-Control
It is common practice to separate front end and back end service for a website. One of the reasons for this is so that we can scale back end or front end separately. Most of the time, we need more resources to serve back end than the front end. To reduce loads that coming to backend we need some caching. Fortunately, there is a Cache-Control header. The back end can control how the front end should cache the resource by using this header. Cache-control is commonly used for image files or static files such as javascript. It also can be used to ajax JSON request or any other request. This article will show you how to use the Cache-Control header to reduce load to back end for your website.
[Read More]Cache Form Inputs With localStorage in Javascript
HTML Form is the most common way to collect user inputs on a website. When there are many fields to fill or there is a field with a long value to input, caching the inputted value is not a bad idea. We cache inputs so users can continue to fill the fields if they accidentally close the page or browser, or move to another page. This article will show you how to cache input with localStorage.
[Read More]