Reducing Services Costs for SPA (Single Page Application)

0

Good afternoon,

I am currently using the following services for an Angular application with Spring Boot (Java) for the back end: Elastic Load Balancing (Application) Relational Database Service Elastic Compute Cloud Route 53 CloudFront

And others but the most costly services are as you already guessed ELB, Relational Database Service and Elastic Compute Cloud.

As result, and for a few users, the bill reachs 50$... it's tremendous for what it is, a single page to upload medias, which is all the more, used once in a while!

I am wondering if Amazon proposes other budget friendly services to host a Spring Boot application with Angular as the front end.

I know I successfully managed to host both using a Lightsail instance, but it was for test purposes. Maybe I should consider deploying a production environment using this service?

But then again is it possible to route my domain name to my Lightsail instance?

Now it feels like I've been ordering a rocket for my application while a paper plane would have been more than enough haha.

Waiting for your answers,

Have a good day!

2 Answers
0

Your options depend a lot on your non-functional requirements. If your site really is used only "once in a while" and your users don't use it very often they may accept waiting 30 seconds or so for a cold start. Then you could, depending on the DB engine you need, shift your RDS DB to Aurora Serverless v1 which scales down to zero. Here's an article talking about a way to front-end your app to let users know the cold start is happening - https://www.linkedin.com/pulse/coping-aurora-serverless-v1-cold-starts-web-steve-kinsman/.

The above article also mentions putting an SPA (Django in that case) in Lambda instead of EC2 to save money. If you google "aws lambda angular" you'll find a bunch of information out there that may help.

Also do you really need an ELB? Unless you need high availability with 2 or more EC2 instances you probably don't need the ELB - you can connect CloudFront to an EC2 Instance origin, protected with a security group allowing ingress only from the AWS-managed prefix list for CloudFront.

EXPERT
answered 10 months ago
profile picture
EXPERT
reviewed 10 months ago
  • Thank you for those precious informations,

    I will investigate this weekend, in the meantime I might consider suspending my services until I can get the budget friendly configuration set up, or else it will be a waste of money.

0

Hello,

Yes you can route your domain name to your servers, whether they are in EC2 or in Lightsail. Since you already have a domain name and manage it somewhere, that process should be as simple as the following:

  1. Create Lightsail instance and attach a static IP to it
  2. Configure the instance per your needs and test it
  3. Create or update the relevant A & AAAA records to point to the instance

The answers above from skinsman are also good alternatives using other AWS building blocks. I would add that for an SPA you may find that a private S3 bucket + CloudFront CDN covers all your hosting needs. CloudFront now provides a pretty comprehensive set of SPA configurations allowing you to use this configuration to host a static site, meaning you do not enable static site features at the bucket level at all. There is a CloudFormation stack already defined for such a setup which is referenced in this guide: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/getting-started-secure-static-website-cloudformation-template.html

The linked guide includes securing the site which may not be a requirement in your case, but it does provide a good reference for adding some compute via Lambda if that is necessary for your application.

-Andy

AWS
MODERATOR
answered 10 months ago
  • Thank you for these suggestions,

    As my time and experience are limited on this domain I need to follow a decent tutorial about Angular + Spring Boot Application with AWS. It was I miracle I managed to serve it with the services I have mentioned in my first post, but unfortunately it is very expensive.

    I deleted everything to start from zero again using the proper services this time, and in the most convenient way to do it.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions