The Tech Diaries Vol 1. Amazon Web Services - Stake Global

The Tech Diaries Vol 1. Amazon Web Services

A behind-the-screens look at what goes into being a global leader in digital brokerage.

29 March 2021

The Stake community is filled with more than just traders and investors. Within this group are engineers, entrepreneurs, and innovators wanting to know how our platform is built. To begin, let’s look at the way we integrate with the best in class cloud solutions that our partner, Amazon Web Services, develops.

API Gateway

Our team has been hard at work to launch API Gateway, an AWS managed service that allows infrastructure engineers to easily maintain and secure APIs at any scale

What are some of the benefits of API gateway?

Stake’s mobile app and website communicate with its servers via a RESTful API layer. API Gateway has all the benefits of enterprise-grade middleware including:

  • Easy monitoring of API usage and changes
  • Cloudwatch logging and alarms alerting the team at busy times
  • Serverless infrastructure with automatic scaling

As our number of users continues to grow, serverless scaling and extensive monitoring become critical to providing a seamless experience around the clock.

API Gateway and Microservices

As Stake continues to build out its microservice architecture, client-to-microservice communication becomes a critical element to consider.

One approach would be to have direct client-to-microservice communication, whereby a client app can make requests directly to some microservices, as follows:

However, realistically the example above is not practical. Client apps usually need to consume functionality from more than one microservice. Therefore, introducing an intermediate level (or Gateway) between microservice-based applications can help us avoid the following problems:

  • The need to roll out a new app version and force users to update
  • Too many round trips between client apps and servers (which would add latency).
  • Further security issues by exposing too many microservice endpoints to the internet.

Therefore, an API gateway can act as the intermediate proxy between client application requests as follows:

In fact – you can (and we do) have many API gateways talking to each other, but without getting too complex, hopefully, this simple example has illustrated some benefits.

SQS (Simple Queuing Service)

In the brokerage world, speed of execution and information flow in real-time becomes absolutely pivotal. We all want to know the second a stock becomes ready to trade after IPO, immediate feedback on trade executions, and our portfolio balance marked to the latest stock prices.

With millions and millions of requests and messages passing through our system every month, we need to make sure nothing goes missing!

There are lots of different ways of managing this – and one way we are currently using is a simple queuing service.

One example is when our broker executes trades. Our broker publishes messages about the execution to an SQS queue, which Stake then receives. Stake redistributes these messages to queues sitting in all of its AWS data centres. Receivers of these messages are called consumers. When a consumer receives a message it may execute some code.

For example, a consumer has been built to give you notifications of real-time execution via email, and also making sure that trade execution is reflected in all the relevant places (e.g. holdings and buying power). Once you get to a certain scale, without queuing, any system risks messages not being processed in time (and out of order). Many parts of our business continue to make more active use of this technology, to support both our customers and operations staff having visibility on all things real-time.

S3 Web Hosting

Our desktop platform has been available to Australians and New Zealanders, and we are super excited to get it live in the UK and Brazil.

Up until this point, we have been statistically serving the site from AWS on a dedicated EC2 out of a single datacenter.

UK and Brazil change the game. We of course want the best possible experience for all our customers across the globe!

By transitioning our web hosting to utilise S3 and making use of AWS’s extensive edge-location network for geo-located caching, we are making sure our UK and Brazilian customers get the best possible browser experience.