Prerequisite

Basic understanding of rate limiting algorithms. You can refer the following blog to understand about different rate limiting algorithms:

Assessment of all libraries explored

I found 4 candidates for rate limiter. Below is the comparison of all 4:

Link: https://redislabs.com/redis-best-practices/basic-rate-limiting/

Pros: No need to import additional package

Cons: No burst capability. No information to retrieve remaining, retry and reset information.

Link: https://github.com/gojekfarm/go-ratelimit

Pros: Simple to implement because it is just an improvement from Basic Redis Rate Limit.

Cons: Not Future Proof. Last updated 4 years ago. No burst capability. No information to retrieve remaining, retry and reset information

Link: https://pkg.go.dev/golang.org/x/time/rate

Pros: Simple to implement. Works…


Indexing is a way to optimise the performance of a database by minimising the number of disk accesses required when a query is processed. It is a data structure technique which is used to quickly locate and access the data in a database.

Indexes are created using a few database columns.

  • The first column is the Search key that contains a copy of the primary key or candidate key of the table. These values are stored in sorted order so that the corresponding data can be accessed quickly.
    Note: The data may or may not be stored in sorted order.


Requirements and Goals

  • To limit the number of requests per client in a particular time window. For example, a client is only allowed 100 requests per minute.
  • Rate limit should be considered across different servers of a service. The user should get an error message whenever the defined threshold is crossed across a cluster of servers.
  • Explore different types of algorithms used in rate limiting.

Why ?

  • To prevent DDOS attacks
  • To eliminate spikiness in traffic from one client. For example, a client may make requests in abundance in a particular time period, leading to starvation of other clients.

High Level Design (HLD)

Bring the rate limiting configurations of…


Load balancing is an excellent way to scale out your application and increase its performance. It distributes the incoming traffic across multiple servers configured behind it. NGINX acts as a single entry point to a distributed web application working on multiple separate servers.

Redirecting traffic to a Group of servers

Assumption: I’m assuming that you have NGINX installed on your local machine and it is up and running. If you need help installing NGINX, you can follow this link.

Note: Every time you make changes to the nginx.conf file, you need to reload your nginx server. You can do this by running the following command:

nginx -s…


Before getting into 2-way ssl, we need to understand what asymmetric cryptography is.

Asymmetric cryptography

Asymmetric cryptography is a process that uses a pair of related keys— one public key and one private key — to encrypt and decrypt a message.

A public key is a cryptographic key that can be used by any person to encrypt a message so that it can only be deciphered by the intended recipient with their private key.

Initially, a pair of private and public key is generated at the sender’s end and the receiver’s end. These keys can be generated using DSA algorithms. To know…


DEFER

A defer statement pushes a function call onto a stack. The stack of function calls are executed when the surrounding function returns. Syntactically, a defer statement is an ordinary function or a method call prefixed by the keyword defer.

func printStrings() {
1. fmt.Println("Beginning of the function")
2. defer fmt.Println("Deferred Call")
3. fmt.Println("End of the function")
4.}
OUTPUT:
Beginning of the function
End of the function
Deferred Call

When go recognises that the surrounding function exits(line number 4), it looks to see if there are any deferred function calls on the stack(line number 2 in the above example). …


We all come around situations during programming, where we need to determine the types of variables or functions. Sometimes, there comes a use case when you don’t actually know the type of variable when the program was written(during compile time), but you need to determine it at runtime. Maybe, you want to map a network request into a variable or build a tool that works with different types. So, reflection could be a possible solution for these kinds of problems.

Reflection is the ability of a program to identify types of variables or functions at runtime. …

Aman Jain

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store