Posts
Websockets, Dealing with realtime updates for async API
Problem Recently I came across a scenario at work where I had to deal with real time updates of payment status in mobile which involved an asynchronous chain of events in the backend. Mobile would call the backend to initiate a payment request, backend would do basic validation - initialize the payment and return a token to the UI. Actual payment involved multiple API calls to some of the internal systems as well as third party systems.
read morePosts
Database Connection Pooling
DB Connections are expensive Normally following things happen when your backend service talks to a database:
service initiates a connection to DB using the database driver
db does the authentication and establishes a network session (tcp) if succeeded
program/service performs some db operation (CRUD) which follows authorization (if user/role is allowed to perform the requested operation)
Now if the service decides to close the connection, it has to do these all over again which is quite an expensive process.
read morePosts
Debugging driven development (is bad)
We have pretty powerful modern IDE and tooling around debugging (including structured logging and so on). It’s so easy to yield to this paradigm of programming. Now I think it’s quite a bad thing. Here are my reasons:
(disclaimer - my reasons against debugging only when considered as a primary approach to coming up with solution)
too much reliance on debugging (if something goes wrong step through) takes away a key thing (thinking from first principles).
read morePosts
How I work
I have been working as a professional software engineer for over 4 years now and along the way I have picked up some heuristics about how should I take the task in hand.
Clarification
Getting a crystall clear clarity of what you are going to implement is of paramount importance. Pay as much attention to details as possible. It’s okay to conduct few more meetings with teammates on getting clarification rather than doing a root cause analysis for a misunderstood or a buggy code down the line.
read morePosts
Accessing Cloudwatch logs via AWS CLI
AWS Cloudwatch cloudwatch allows to take a peek into your aws applications, their logs and other metrices. Apart from the centralized logging (kibana,loggly) where we limit retention duration (cost factor), cloudwatch provides a way to do pay-per-volume query operations.
AWS CLI installation on mac
configuration aws configure Setting up AWS keys
Although cloudwatch comes with a nice GUI, we can leverage CLI to automate and ease up some tasks. Here is a use case for filtering logs and downloading them for further analysis.
read morePosts
Get the most out of your command line experience
up arrow key takes you to a list of recently used commands
history command lists out the history of your commands (size as configured)
you can search in your history by using (ctr-R), helpful if you know some keyword
You can tag your commands with comments for ease with history search
eg : some esoteric command #fixes-all (You can reverse search using fixes-all)
all your commands in history are numbered
read morePosts
Parallelism, Concurrency And Golang
Concurrecy Vs Parallelism (Go-lang Example) This is the general understanding of concurrency vs parallelism.
Parallelism: Having multiple threads do similar task which are independent of each other in terms of data and resource that they require to do so. Eg: Google crawler can spawn thousands of threads and each thread can do it’s task independently.
Concurrency: Concurrency comes into picture when you have shared data, shared resource among the threads. In a transactional system this means you have to synchronize the critical section of the code using some techniques like Locks, semaphores, etc.
read morePosts
Idea of 'closure' in functional programming
Closure The inner function has access to variables which were in the enclosing scope even after that ’ennclosing scope’ execution is over. (Inner function gets a copy) This is my attempt to understand why is this such an important concept in functional programming, why is it named so and so on… Functions are first class citizens In functional paradigm of programming functions are considered as ‘first class citizens’. This means functions can be
read morePosts
Monoliths Vs Microservices
Microservice is not the silver bullet Software Industry is heavily trend-driven. People love going behind the trendy hypes
microservices are cool containers are cool noSQL is cool this new language/framework is cool what makes a good use case for microservice? functionality has very clear demarcation/boundary (the most important.. don’t try to force split an already domain complex module) functionality needs independent scaling functionality needs lot of re-use (many components need it) functionality demands language agnosticity (rapid iterations, deployment) what should you ensure?
read morePosts
Debugging Slow Queries In Backend
What are the things that should be on your checklist when you are facing a situation where your db queries are taking a lot of time?
Cross check simple things such as if you would require pagination. If your filters are none (or too broad) even with optimized query plan/indexing query can take some time.
Take the slow query, view the execution plan and cross check if you would require indexing, if your query is set to run with the indices (eg: is the query properly making use of functional indices?
read more