- Published on
Deploy and Maintain Paytungan Infrastructure
- Authors
- Name
- Advis Tasyah Mulia
- @licacila_
In software development, creating the right infrastructure for software is a step to meet the application's needs, expansion/scalability, and data security. On several occasions, some software engineers overlook the system and infrastructure aspects of software due to a focus on the user interface. Paytungan is a split bill application based on a web application. But what does infrastructure generally mean in a web application?
Software Architecture
The software architecture of a system explains the relationship between each component and how these components interact. In short, software architecture acts as a blueprint that provides abstraction to manage the complexity of the system and implement coordination/communication between components.
The architecture of a software system should be designed with specific objectives. These specific objectives must align with the purposes of the tools or equipment used. The functionality and requirements of software impact the selection of devices used, so the software must be well-crafted and mature.
Capacity Planning
It is possible to encounter limits when hitting the services we provide due to various reasons, such as an increase in the application's user base. These limits can cause incidents that make our application difficult to access and can adversely affect its business operations.
Therefore, before determining the infrastructure for each service, we create planning that aligns with the expected workload on the designed application. There are several concepts that need to be addressed during capacity planning:
- With the expected number of users and workload hitting the service, how much initial capacity is needed?
- How much unused capacity exists in the current iteration?
- With iterations revolving and the user base increasing due to new features, is it necessary to scale the infrastructure in this iteration?
- Does the current infrastructure support ease of scaling/expansion?
Backend Infrastructure
Our backend application uses Google Cloud Platform as the cloud provider. This choice was made because GCP is user-friendly, and each PPL team was given a $50 credit to set up their own infrastructure. Our Django application runs on Cloud Run, which can be easily scaled. At the time this article was written, we have 3 instances within 1 Google Compute Engine virtual machine and one PostgreSQL instance as the database.
Frontend Infrastructure
Our frontend system uses PAAS (Platform As A Service) Vercel as the host for the Next.js application we've built. Several considerations were made before choosing Vercel as our frontend server host. The reasons for this choice include:
- Vercel is the creator of the Next.js framework.
- Vercel offers auto-scaling, eliminating the need for us to handle instance additions.
- Vercel CLI makes it easy for developers to create CI/CD code to deploy to Vercel instances.
- Integrated usage analytics provide Paytungan's team with insights to monitor data ingress and egress as well as the daily request volume on our website.
Error Handling Using Sentry
Errors in an application can occur due to various reasons, including:
- Logical errors
- Generated errors
- Compile-time errors
- Runtime errors
Error handling refers to the activity of responding to an error and making efforts to fix it. Before implementing error handling, developers need to understand the errors that occur and resolve them quickly. To quickly identify information about the error, proactive measures and monitoring are required as an initial detection of errors. In reality, errors can happen at any time in an application and pose a challenge to every developer.
Sentry is a tool used for error monitoring. It provides libraries and SDKs that can be installed according to the programming language used. For example, in our backend application, we installed Sentry to monitor when the code encounters errors (usually happening within try-catch blocks).
To expedite our acknowledgment of errors, we implemented a Sentry webhook and installed it on our Discord server. This way, every error that occurs triggers notifications as alerts for us. We aim to quickly apply hotfixes and identify the root cause as soon as an error occurs.