We looked at deploying your application such as Ruby on Rails with Heroku.
Now we may explore things like server-less design.
Re-platforming is a big topic and a large undertaking. Before beginning to re-platform, one must carefully weigh the technical advantages, disadvantages, cost and time associated to it.
Here’s a breakdown of why I think it’s worth re-platforming my site:
Ruby on rails is great but:
- There’s not many ruby engineers if looking to expand your team
- Can be slow for certain tasks including heavy processing of data
- Requires me to have a server running 24/7 even if it’s not serving anyone
- It’s a monolith and will accrue tech debt over time
For me point 3 is probably one of more important ones. My website is currently not very visible to public and is hardly used. Do I really need to pay for a server running 24/7?
Note that I am still a massive fan of Ruby on Rails architecture – micro service architecture are not a silver bullet for starting a website and you should do your research before choosing the framework that suits you and your needs.
So assuming you already have a website and you want to start exploring micro-service architecture but don’t know where to begin – let’s delve into it!
First of all, you may need to decide on what you’re going to separate first – let’s look into a simple design diagram (made with paint, I am not a designer sorry!)
So you may have 1 server which is holding both your front end and back end code. Your backend code also holds all of your controllers for handling any API requests. And your application is also communicating to a database which is usually not on the same server.
There are many visions for a micro-service architecture, but let’s put one out there
This is actually an over simplification. There’s many things which are not visible but these are the largest parts. Also if using lambdas, it wouldn’t be a ‘controller’ which sits in the function, but one of the functions from the controller.
e.g. You may have a standard CRUD (CReate, Update, Delete) controller and for the 3 functions, you should have 3 lambda’s.
There’s many advantages and disadvantages of going into this architecture and this can be covered later as this isn’t the purpose of this post.
I am currently laying out a small strategy for how to get from A to B.
First of all, you’d want to have little to no downtime at all. So I think the first step should be to migrate the database. If using AWS, consider switching to RDS or whatever you need. In reality, it’s not essential, but I think it will make things easier when developing the new functionality.
Note I haven’t gone through these steps yet and there will be posts for doing these migrations, but I will look to follow the Heroku guide on enabling the use of AWS RDS database. I will use heroku postgres database feature to make a backup of the database and clone the AWS RDS from the backup created.
This will involve some downtime so if you cannot afford downtime, a different means should be investigated, such as creating a database and synchronising it with the one you’re using then making the switch (similar to a failover strategy).
After this is done, I will start either implementing a new function using AWS lambda, or take 1 existing function that’s in ruby and implement it in lambda. Then when I call the ruby controller for it, I will redirect the request to AWS lambda for response.
Over time you should aim to move all active requests over to AWS microservices. By the way, they can still be running on small EC2 instances, which in some ways may even be easier to do for some people.
Once the controller methods are already migrated, you should consider re-platforming the routes functionality. i.e. the API Requests gateway.
Finally, I will look to migrate the front end code, which is currently a SPA in React to an S3 bucket and publish it live. This will require some fiddling with domain name configurations and access controls.
These are the large chunks of things required to do and to be fair most can be done in any order.
Stay tuned as I will start this process within the next few weeks.
Also, I have recently done the AWS Advanced training course, which gave me some motivation to do this – it was very interesting and for those considering they should just jump into it!
And for reference, the website that we’re re-platforming is www.yazii.co.uk which is a website for searching tech jobs in UK. It has over 10 million records in database (not job posts, but just data) so it’s already in a state where you wouldn’t want to lose the data.