14.08.2024

From Single Server to AWS: The Evolution of Pedagogas.lt

In the field of web development, the transition from a single-server setup to a cloud-based infrastructure is becoming increasingly common. Adapt Lithuania's DevOps engineer Deividas Pekūnas shares his experience and insights from the Pedagogas.lt project, which recently underwent a transformation by moving from a traditional single-server architecture to Amazon Web Services (AWS). This shift offers valuable lessons for developers and project managers considering similar migrations.

code adapt

The Single Server Era

Pedagogas.lt, like many web projects, began its life on a single server. This setup hosted multiple applications and a shared database, a common approach for smaller projects. However, as the project grew, the limitations of this architecture became apparent. Debugging was a complex task, with multiple applications intertwined, making it difficult to isolate issues. Scaling resources to meet the demands of individual applications was nearly impossible, as any change affected the entire system. Maintenance became increasingly time-consuming, with updates and security patches requiring careful coordination to avoid disrupting the entire system. Perhaps most critically, the shared database created potential performance bottlenecks and security concerns.

These challenges are not unique to pedagogas.lt. Many small, but growing web projects face similar issues, signalling the need for a more robust and flexible architecture.

AWS single server

Embracing the Cloud

As pedagogas.lt outgrew its single server setup, we saw an opportunity to reimagine our architecture by migrating to Amazon Web Services (AWS). This move was more than just a change of location; it was a comprehensive redesign of our entire system.

AWS migration

Amazon's Elastic Container Service (ECS)

Our journey began with addressing the core challenge of scalability. The main goal was to achieve a system that could easily handle larger traffic peaks during busy periods and then scale down when activity was low. We needed a solution that would allow us to effortlessly launch new application instances on demand. This led us to Amazon's Elastic Container Service (ECS).

For those not familiar with it, ECS is Amazon's way of helping developers run and manage applications in the cloud. Think of it like a smart manager for your Docker containers - it handles all the complicated stuff like where to put your containers, how to keep them running, and how to scale them up or down as needed.

ECS turned out to be a great fit for our project, bringing both cost savings and powerful features. The cost model is pretty neat - we only pay for the servers we actually use, while ECS itself is free. It's like getting a high-end container management system as a bonus. But it's not just about saving money. ECS came packed with features that matched our needs perfectly. For example, we can easily run our Docker images, which was already part of our workflow. Even better, ECS supports blue-green deployments. Essentially it's just a fancy way of saying we can update our app without any downtime. This means our users don't experience any interruptions when we roll out new features or fixes. All these benefits made the switch to ECS feel like a real upgrade for our infrastructure.

Amazon EFS for Seamless File Management

As we scaled up our pedagogas.lt application to run on multiple servers, we encountered a common challenge with file management. Each server needed access to the same set of important files, like user uploads and settings. This is where Amazon's Elastic File System (EFS) proved valuable. EFS is like a giant, shared hard drive in the cloud that all our servers can access. By using EFS, we ensured that every server always had the latest files, no matter which one was handling a user's request. Think of it like a single, shared notebook for all our servers, keeping everything neatly organised and up-to-date.

Next, we tackled the challenge of logging. Running an application across multiple servers and keeping track of what's happening can get tricky. We needed a way to see all our logs in one place, instead of having to check each server individually. That's where Amazon CloudWatch came to the rescue. To keep things efficient, we use the CloudWatch agent, which collects and sends logs in batches, ensuring we get all the necessary insights without slowing down our application.

An important aspect of our migration was moving our database to Amazon's Relational Database Service (RDS). It takes care of backups, monitoring, and maintenance tasks, and it also helps us identify and optimise slow queries. RDS allows us to easily increase storage capacity, upgrade RAM, or switch to more powerful CPUs as needed. This flexibility ensures that we can smoothly adjust our database server to meet future demands.

Initially, our application relied on storing user sessions in the local filesystem. Not only did this make session data inconsistent across servers, but file read/write operations could become a bottleneck during peak usage. To address this, we implemented Amazon ElastiCache, a Redis-based solution in the cloud. This transition to ElastiCache ensured consistent data across all servers and eliminated the potential file I/O bottleneck.

With ElastiCache in place, we continued to refine our application for the cloud environment. A key improvement was implementing AWS Systems Manager Parameter Store (SSM), a centralised, encrypted storage for our application's sensitive information. This might sound technical, but it's essentially a secure vault for our settings and secrets, such as database credentials, API keys, and feature flags. Unlike traditional file storage, SSM is specifically designed to manage these critical data elements safely. The best part is how seamlessly SSM works with ECS, letting our containerized application securely fetch these parameters as needed.

AWS file management

Simplifying Deployment with Terraform

One more crucial aspect of our cloud migration that we haven't touched on yet is the adoption of Terraform for infrastructure management. This "Infrastructure as Code" approach brought several key advantages to pedagogas.lt. With Terraform, we can now recreate our entire infrastructure using just a few commands, which greatly simplifies the setup of development and staging environments. This means we can quickly spin up identical environments for testing new features or replicating production issues. Moreover, all changes to our infrastructure are now version-controlled, allowing our team to track modifications over time and rollback if necessary. An additional benefit of this approach is that it significantly eases the onboarding process for new developers. Since our entire infrastructure is defined in code and stored in our repository, new team members can quickly grasp how our project is structured and deployed. This transparency accelerates the learning curve and enables developers to contribute more effectively from day one.

Pedagogas.lt will now operate with greater flexibility, improved speed, and support a substantially larger user base. The new infrastructure has also simplified our management and update processes. While the migration presented its fair share of challenges, the outcomes have justified the effort. Our application is now well-positioned for future growth and evolution in ways that weren't possible with our previous setup. This cloud migration has opened up new possibilities for pedagogas.lt, and we're looking forward to leveraging these capabilities to better serve our users.

Lessons from the Cloud: Designing for Future Scalability

Our journey with pedagogas.lt offers valuable insights for developers at any stage of their project. While the benefits of our AWS migration were significant - improved scalability, easier debugging, reduced maintenance, and better resource utilisation - we also faced challenges. There was a learning curve with AWS services, and the initial setup required considerable effort. However, these hurdles taught us the importance of designing for scalability from the start, regardless of your project's current size.

When building your application, consider using remote storage solutions instead of local ones, set up centralised logging practices, use Redis for session and cache management, and adopt a stateless design where possible. Implement external configuration management and avoid storing critical data in the application layer. These practices not only prepare you for future growth but also improve your app's performance and maintainability right from the start.

Remember, the goal isn't to over-complicate your project, but to make smart decisions that keep your options open. By incorporating these scalable design principles early, you're setting your project up for success, whether it stays on a single server or expands to a large-scale cloud infrastructure. In the rapidly evolving world of web development, preparing for growth isn't just a good idea - it's essential. The story of pedagogas.lt serves as a reminder that thinking ahead and designing with scalability in mind can make all the difference in your project's future.

Final thoughts

This is just the first chapter in our ongoing AWS adventure. We're currently undergoing a full data migration, and there are still optimizations and improvements planned for the future. This article scratches the surface of our experiences – behind each decision and implementation lie numerous technical details, challenges, and learnings. If you're interested in diving deeper, stay tuned! We plan to cover more in-depth technical details, specific AWS service configurations, and advanced optimization techniques in future articles.

We can help

Our agency specializes in guiding businesses through this process, ensuring that they select a solution that aligns with their long-term goals and market demands. Let us help you navigate the complexities of your platform to find the perfect fit for your unique needs.

Let's talk

If you want to discuss this or have IT dilemmas of your own, don't be shy to reach out

Linas Balke

Linas Balke

CEO of Adapt Lithuania