Serverless at Sea
![Serverless at Sea](/content/images/size/w960/2023/06/Serverless-at-Sea.png)
This entry presents my recent session at AWS Community Day at Warsaw National Stadium. Nothing too fancy :)
AWS Community Day
It has been a few weeks already since the AWS Community Warsaw event and the dust is still settling. I had the pleasure and honor to be one of the speakers, among many other great and awesome people there.
![](https://wojtek.cloud/content/images/2023/06/image.png)
Probably it has been my first big and public presentation since college and I think that I can honestly say, that it went quite well, based on rather quite generous review results rated from 1 to 5 and feedback.
Please rate the quality of the session content | Overall, how satisfied were you with the session? | Please rate the quality of the session instructor. |
4,52 | 4,52 | 4,89 |
Feedback:
- Interesting story. Cool solution.
- Interesting presentation, great speech
- Cool presenter, interesting topic, creative cloud usage.
- Would like to see more AWS content
- Something was missing, a little unsatisfied. No information, on where the presentation will be available. Cool topic, real use case, maybe add some cons
- More sailing less cloud, but shows very interesting use case😁
Introduction
This entry is focused on a simple yet original use case and there is more content about sailing and backstory rather than AWS and cloud. There was literally one slide (out of twenty) containing AWS stuff. I really hope, whoever wanted the information on where to find the presentation, will find this. Hopefully, in the future, I will have something more AWSy and cloudy to present.
The solution presented here is a ship-tracking implementation powered by AWS. It is simple, yet effective and uses most basic AWS services.
The ship
![](https://wojtek.cloud/content/images/2023/06/Serverless-at-Sea-1-.png)
This is STS Fryderyk Chopin, where the whole thing is working as I write this and hopefully still working as you read this. It is the second-biggest Polish tall ship and also the second-biggest brig in the world, that travelers the seas.
The Blue School
![](https://wojtek.cloud/content/images/2023/06/combined.jpg)
STS in STS Fryderyk Chopin stands for Sail Training Ship and is still its primary purpose. Youth aged from 14 to 18 years old are sailing around the world, learning about seamanship, duty, responsibility, and life as a crew, while still having regular school classes like Math, Biology, English, etc.
More about it here: https://www.niebieskaszkola.pl/
Ship Tracking
There are several reasons for tracking ship position. The first and most important one is safety, where in case of emergency when there is distress, the position needs to be known so that assistance can be rendered. For this, there is precise and certified equipment on board.
Another use is position tracking during a race or regatta, like for example Tall Ship Races, where you can track all participating ships' progress.
![](https://sailtraininginternational.org/app/uploads/2016/06/bergen-crew-parade.jpg)
The last reason is the parents who really like to know where in the middle of the ocean, their kids are.
YB Tracking
The original tracking solution that was in place was powered by YB Tracking, where a dedicated device, costing 469 GBP + tax, was transmitting the position over satellite connectivity and updating it on the map at YB Tracking website. The cost of operation was 20 GBP per month as a subscription fee and 0.0045 to 0.14 per position update. The second cost variation comes from a subscription package, where the total cost depends on how many tokens (used for updating position) you buy at once.
This is where the need for this cloud solution was born since the device broke and an alternative was needed, especially since when something brakes on the ship, you need to fix it or find a solution usually using the equipment and resources that you have on board, especially when you're in the middle of the sea and closes port is days away.
![](https://static.wixstatic.com/media/3b3cc7_3a0c823c38c146d8b494279e188102c4~mv2.png/v1/fit/w_2500,h_1330,al_c/3b3cc7_3a0c823c38c146d8b494279e188102c4~mv2.png)
Immediate Solution
![](https://wojtek.cloud/content/images/2023/06/Untitled-Diagram-1-.jpg)
The immediate solution to the problem was to simply send an email with the ship's position over satellite connectivity. How and why is there satellite connectivity on the ship, will be converted in a moment.
The idea was, that every four hours, a person (mate) on duty, would send an email to the office with the ship's position. Then the secretary at the office would log in to YB Tracking website and update the ship's position manually, using the location spoofing option. The whole thing obviously worked, wasn't too complicated, but it was manual on both sides.
Watchkeeping
A ship is considered to be in operation for 24 hours and safety is the most important part of sailing. Therefore the crew is divided into three watches, and each watch is responsible for the ship during their work periods. Each watch consists of a mate (officer) and crew members. Tasks are varying, depending on the situation.
If the ship is on the way, the mate's job is to maintain a proper course, monitor the equipment and situation, avoid a collision, and so on. The crew is responsible for steering, and keeping an eye out for other ships and danger.
If the ship is anchored or moored, then the watch is making sure that it stays that way, no one unauthorized tries to board the ship, etc.
When it comes to the position update, sending one email at the end of your watch is not really a big inconvenience, but it is still an additional task you need to remember about.
Keeping ship operational for 24h:
- 1st Watch - 1st Mate:
- 00:00-04:00
- 12:00-16:00
- 2nd Watch - 2nd Mate:
- 04:00-08:00
- 16:00–20:00
- 3rd Watch - 3rd Mate:
- 08:00-12:00
- 20:00-24:00
Sattelite Connectivity and GMDSS
GMDSS stands for Global Maritime Distress and Safety System and it is a mandatory system for automated and improved emergency communication. The further you sail from shore, the more equipment you need to be able to call for help when needed. It is (and looks) old but is tested and reliable.
INMARSAT-C is one part of this system, that allows to send a distress over satellite connectivity, as well as send and receive emails. It is mandatory for ships traveling in A3 sea area, where coast stations are out of radio range. More about sea areas is in the link below. Besides distress, INMARSAT-C is used for receiving weather forecasts and navigational warnings.
![](https://icomuk.co.uk/images/Icom/fieldsetField/70/GMDSS_illustration_edit.jpg)
IridiumGO
Besides INMARSAT-C, STS Fryderyk Chopin is equipped with another satellite communication device called IridiumGO, which is not considered part of GMDSS. It is mainly used for getting good weather forecasts but also allows voice calling, sending text messages (SMS), and emails. It also has its own position tracking and most importantly allows automation.
Partially Automated Solution
![](https://wojtek.cloud/content/images/2023/06/Untitled-Diagram-2--2.jpg)
With IridiumGO we can automate the process on the ship's side, where now it sends a position update every four hours. However, the office still needs to update the position on the website automatically, and also the office does not work 24 hours per day so the position will not be updated outside of working hours. Additionally, there is a difference in the format of the position sent by IridiumGO and the one you need to enter into the website, so some recalculation is needed, which creates a possible error when done manually on the office side.
Cloud Solution
![](https://wojtek.cloud/content/images/2023/06/Untitled-Diagram-3--1.jpg)
Finally, we come to the AWS solution, where we automate the office position update part using a few AWS Serverless services. Email is sent to Simple Email Service, which triggers a Lambda function that logs in to the YB Tracking website via API using credentials stored in Secrets Manager. Now the position is updated automatically every four hours.
Costs & Savings
Here are the costs & savings of the final solution. AWS service usage is minimal and covered by the free tier. IridiumGO costs might seem quite high for a simple position-tracking system, however, those costs were there before. To recall, IridiumGO, on the ship, is mainly used to retrieve weather forecasts and the cost of an unlimited plan was the best option. So theoretically this cloud ship-tracking did not add any new costs and actually provided some savings, as listed below.
Costs:
- IridiumGO monthly cost: 154 USD + TAX - for unlimited connectivity
- AWS Resources - 0 USD - all part of the free tier
Savings:
- 500 GBP for a new device
- 20 GBP per month for YB Tracking subscription
- Tracking token costs - 0.045-0.14 GPB per update
Pains, issues & problems
During the creation and development of this solution, there were some small problems and hiccups, however, there were small enough to either be resolved or ignored.
The first pain was the YB Tracking website API. It is not documented and is not really meant to be used as an API. This led to some reverse engineering to get a nice and simple Lambda that only uses a few POST and GET calls. An alternative was to use Selenium and web scraping, however, it did not come to that.
The second small problem, that was ignored in the end, is the IridiumGO GPS position variations. With the ship staying in the same position for a longer period of time, it would report positions that could vary in like 100 meters or so. However, since this is only a map tracking position and it is not being used as a safety system (there is dedicated equipment for that), this issue can be neglected. The variation come most likely due to IridiumGO antenna position and interference from all metal parts of the ship which is almost completely made from metal.
The last hiccup was the initial AWS region. SES is a rather old and common service, there's nothing new there, however for some reason eu-central-1 region does not support email receiving. I was really surprised since it was discovered during the development process and everything had to be moved to eu-west-1.
Debugging Example
Here is a simple example of debugging the solution, by launching Lambda and updating the position on the map. The map above shows "stairs" on the Atlantic Ocean, on the left side of the shores of Portugal and Marroco.
If you want to check the exact position of the ship now, you can head to this link below.
Why not Starlink?
One of the questions, I assumed to receive was "Why not use Starlink?". It is cheaper on paper and can provide high Internet speed. Well, as it is with most stuff, it depends.
Below is a quick comparison of IridiumGO, Starlink, and Starlink Maritime. The main issue with Starlink is that it operates inland, so while you can have nice and fast connectivity when ashore or close to shore, it will not work in the middle of the ocean. There is a dedicated Starlink Maritime for that, however, the price is way higher and out of the ship's budget.
- IridiumGO speed: 2.4 Kbits/s
- Starlink speed: 50-500 Mbps
- Starlink costs:
- Hardware: ~645 USD (2 720 PLN)
- Subscription: ~80 USD (335 PLN)
- Starlink connectivity is inland & coastal
- Starlink Maritime costs:
- Hardware: ~3 215 USD (13 601 PLN)
- Subscription: ~327 USD (1 384 PLN)
- Starlink Maritime covers oceans
Summary
![](https://wojtek.cloud/content/images/2023/06/8a99b1dc8fe19ab3483de93e2d41bde9.jpg)
The main idea of this presentation was an original cloud use case. The summary of this is that a simple solution can work or even may work best. Cloud can be used even in places with limited connectivity and you can literally launch any workload you want using a simple email as a trigger.
Regarding the future of this, there actually is a possibility to develop this further, so I might actually do a follow-up. After the presentation, I was approached by one of the few sailors that were present in the room and he told me that he was thinking about something similar, where based on the position of the ship, an email would be sent with the precise weather forecast for the ship's location.