FestivalTickets - High Scalability Sample

Official Content
This documentation is valid for:

FestivalTickets is a Web application that allows participants to register for events. 

A key characteristic of this system is that it must be able to handle massive numbers of users, scaling properly for 1 user as well as for millions of users. In addition, this system must be deployed in the Cloud, using the Cloud services provided for maximum scalability at the lowest possible cost. 

BigBearFestival

In this example, you can see an application with an architecture that involves multiple components, the GeneXus model to generate those software elements, and the code that was written to create the infrastructure on which the application runs.

The architecture of the application obtained has the following components:

  • Single-page application (SPA) hosted on a serverless environment (Amazon S3)
  • Functions running on a serverless, event-driven compute service (AWS Lambda), served through an API gateway (Amazon API Gateway)
  • Message Queues on a serverless service bus (Amazon SQS)
  • Data stored depending on its nature and purpose in a:
    • Key-value NoSQL database service (Amazon DynamoDB)
    • Serverless object storage service (Amazon S3)
    • Relational database service (MySQL on Amazon RDS)

In this first version of the sample, the SPA was generated with Angular, and the rest using the Java Generator; everything runs on Amazon WebServices (AWS).

Live demo, etc.

Demo: https://youtu.be/D2kk6bItomM (Spanish audio)
KB Tour: https://youtu.be/zN-zDWkKzAk (Spanish audio)
AWS first steps: https://youtu.be/0_XmJpnrUbY

Angular App: https://d3fleuy2n9drfh.cloudfront.net

Note: FestivalTicketsHome is the Main Object for Angular. BOHome is the Main Object of the backoffice.

Architecture

image_202272914238_1_png

Since it is a highly scalable application, it was decided to use a serverless solution similar to the one used in the “Coronavirus UY” app.

Why Serverless?

Because it allows us to scale the computation indefinitely through the AWS Lambda Platform, paying only for what is used. If there are no requests, the cost is 0. It also allows us to use services managed by the cloud, which don't require intervention from our team.

The solution has the following features:

  • Frontend (HTML/JS/CSS)
    • Generated in Angular and stored in AWS Amazon S3. 
  • Frontend services backend
    • Angular App services are hosted on AWS Lambda using API Gateway as API Mediator. Generated using Java technology. 

Data reading is performed against a non-relational database: Amazon DynamoDB.

Why AWS DynamoDB?

Because it allows us to scale indefinitely in terms of data storage. 

As for writing, when a ticket is created, it is sent to a message queue called Amazon SQS, and in this way the response is immediate. This message queue will be automatically processed by a lambda function called "ProcessTicketQueue." It will store the tickets in Amazon DynamoDB and MySQL.

The draw is performed by another lambda function called "ProcessTicketRaffle" of timer type that checks periodically if there is a closed event. When it finds a closed event, it performs the ticket drawing, assigns the winning tickets, and ends the event.

Amazon S3, Amazon SQS, AWS Lambda and Amazon DynamoDB services are serverless by definition. For this reason, it is not necessary to manage servers and the application will have a predictable performance, for any number of users.

Source code and requirements

Design

Small: https://share.goabstract.com/b154a720-265a-43c2-8f56-192fc19ef3a7
Large: https://share.goabstract.com/6e222c39-755f-497c-af22-d397c5ea25d6

Sketch file: It is the 'ScalabilitySample_gxsketch' File object in the KB.

KB

GXServer: http://samples.genexusserver.com/beta
KB: FestivalTicketsKB
License: Apache License 2.0

Requirements

GeneXus BetaGeneXus Java Generator
Angular Generator requirements.

Steps to run the application

  • Create KB from Server
  • In Frontend, select Angular in Main Platform and set "FestivalTicketsHome" as main object
  • Create the necessary infrastructure in AWS (described below) and set the following properties in the KB
    • Endpoint and credentials to the database
      • To do so, access Secrets Manager in the AWS console
         There you will find the generated user and password
    • DynamoDB datastore user ID and password
      • This is returned after the infrastructure is created
      • If using other aws region than us-east-1, please add "Additional connection string attributes": region=us-west-1
    • AWS SQS Queue Connection Information
      • Set EnvironmentVariable: GX_FESTIVALTICKETS_QUEUEURL with the QueueURL provided by the CDK. Or just change it in Procedure: 'BusinessLogic.SQSUrlGet'. 
  • Rebuild All

Infrastructure as Code (IaC)

To make it easier to build the necessary infrastructure in production, an AWS CDK project was created to handle this task, generating and executing a CloudFormation Stack.

GitHub repository: https://github.com/genexuslabs/gx-aws-cdk-samples

In the repository, you can find the requirements and steps needed to create the infrastructure. At the end of this process, the necessary data will be returned to fully configure the KB.

Deployment

The deployment will be performed as follows with each deployment unit:

  • LambdaProcessTicketQueue
    • Target: AWS Lambda Functions
    • Trigger Type: Queue
  • LambdaTicketRaffle
    • Target: AWS Lambda Functions
    • Trigger Type: Timer
  • App
    • Target: Static Front end
  • App
    • Target: AWS Serverless Deploy (backend services)
  • Backoffice
    • It will be possible to select Beanstalk or another such as Docker or EC2 instance

Development process

Several features and criteria of the development process are highlighted below.

Import from Sketch

The design was made in Sketch and then imported into the GeneXus KB through the Design Import option.

Once imported from Sketch, some minor adjustments were made to the layouts to achieve maximum consistency in each layout.
The import from Sketch functionality allowed the development process to be more focused on the business logic.

Development with a coding standard

It was originally developed in GeneXus 17 Beta following the GeneXus Development Guide to create consistent, high-quality code.

StoneFramework Community

The StoneFramework Community Edition module, developed by Daniel Monza, was included because it provides procedures, user controls, and data patterns commonly used in systems.

Unit testing

The example has unit tests to certify the drawing. They can be reviewed in the “MakeWinnersUnitTest” object.

UI tests

A UI test called "FrontendTest" was developed to test the entire ticket creation cycle. It runs through the registration and status check for the created ticket.

Subscribe to KB feed
KnowledgeBase FestivalTicketsKB
GeneXus Server URL here
No news available on this feed