Skip to content

Working demo that can easily demonstrate the Solace PubSub+ Cache capabilities by using terraform & ansible to automate the Infra creation

Notifications You must be signed in to change notification settings

solacese/PS-CacheDemoHA-aws-terra-ansi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solace - PubSub+ Cache Demo deployed with Terraform & Ansible

Overview

This repository is a collection of Terraform and Ansible configuration files, that automatically provision (on the AWS Cloud) the infrastructure required to run Solace Broker nodes (in HA), as well as Solace PubSub+ Cache nodes plus a Market Data Feed Simulator & a Market Data Sample monitor.

The purpose of this repo is to provide a quick way to create from scratch a working demo that can easily demonstrate the Solace PubSub+ Cache capabilities.

The following image is a high level overview of the PS+ Cache configurations to be created on the brokers. It can be observed that we have:

  • 2 sources (exchanges) of Market Data publishing prices to different topic prefixes.
  • Web Clients (WebMonitor App) subscribing to all the Market Data available, either directly or via Cache Requests.
  • 2 Distributed Caches:
    • AMER_DistributedCache to manage Cache Clusters for the "Americas region".
    • EMEA_DistributedCache for future use on the "EMEA region".
  • 2 Cache Clusters (in order to balance the load) within the AMER_DistributedCache:
    • NYSE_CacheCluster - to store all the MD from the NYSE exchange (topic MD/NYSE/>).
    • BMV_CacheCluster - to store all the MD from the BMV exchange (topic MD/BMV/>).
  • 4 Cache Instances "PS_CacheInstance_X" - 2 Instances per Cache Cluster (in order to achieve HA within a Cache Cluster)

PS+ Cache Topology

Warnings

⚠️ This project is intended to serve as a POC for demonstrating the functionality of the Solace PubSub+ Cache, plus the automation capabilities of the Solace Brokers. Therefore, there are several opportunities for improvement. ⚠️ Keep in mind that this code has not been tested or coded to be PRODUCTION ready.

Getting Started

There are 4 main subdirectories in this repository:

  • keys - Used to store the private & public keys to access via SSH the Solace Broker, PubSub+ Cache and Client nodes
  • terraform - Contains Terraform configuration & template files to create resources on the cloud as well as files to be used by Ansible (Inventories, Playbooks, Variables)
  • ansible - Contains playbooks, inventories, variables & roles to be used by Ansible to configure the VMs. There are static files that can be modified according to what is needed, as well as files that will get dynamically created by Terraform upon execution, based on the resources terraform creates (ex: public or private IPs, etc.).
  • images - Contains images for the README files

Inside those subdirectories, there are README files that can provide extra information as well as describing what CAN or HAS TO be configured on each section.

Prerequisites

General

  • A control host that will run the Terraform & Ansible Scripts
  • Install Terraform on the Host - Instructions here
  • Install Ansible on the host - Instructions here
  • Disable host key checking by the underlying tools Ansible uses to connect to the host
      export ANSIBLE_HOST_KEY_CHECKING=false
    

AWS

  • Configure Terraform to use the credentials of a sufficiently privileged IAM role You can do this in a number of ways, but I recommend using environment variables as a quick, easy, and secure way of passing your keys to Terraform. Instructions here.

      export AWS_ACCESS_KEY_ID="accesskey"
      export AWS_SECRET_ACCESS_KEY="secretkey"
    
  • Modify the default identification values for the AWS resources on the /terraform/aws-variables.tf file, set them to something relevant to your demo. Ex:

      variable "aws_ssh_key_name" {
        default = "mmoreno_cache_demo_tfsa_key"
      }
      variable "tag_owner" {
        default = "Manuel Moreno"
      }
      variable "tag_name_prefix" {
        default = "mmoreno-SolaceCache"
      }
    

PubSub+ Cache

  • Get a licensed copy of Solace PS+ Cache Linux binaries, plus a copy of the Solace C API for Linux.
  • Copy your PS+ Cache Linux binaries (ex: SolaceCache_Linux26-x86_64_opt_1.0.8.tar.gz) plus the Solace C API for Linux binaries (ex: solclient_Linux26-x86_64_opt_7.17.0.4.tar.gz) to the path: /ansible/playbooks/bootstrap/roles/solace/solace-cache/files
  • Rename the PS+ Cache Linux binary file to simply "SolaceCache_Linux26.tar.gz"
  • Rename the Solace C API for Linux binary file to simply "solclient_Linux26.tar.gz"

SSH Keys

  • Configure the private & public SSH keys required to login & setup the hosts.
  • Take a look at the README file inside /keys for a more detailed description on how to do it.

⚠️ The SSH keys to be used should have restrictive permissions (ex: 600), otherwise Terraform and Ansible could trigger an error while connecting to the VMs

Creating Resources

Once all the variables and configurations have been set according to our needs, we can have Terraform create all the infrastructure for us, by going into the appropriate PATH where the Terraform resource files are located (in this case: /terraform) and typing the following commands:

  terraform init
  terraform apply

and typing "yes" when prompted.

Navigate to the Market Data monitor Web Application

Once all the resources have been provisioned and configured, you should see a list of IPs:

Terraform Output

Identify the "client-node-public-ips" IP, open a Web Browser, navigate to that IP and you should see the MarketData WebMonitor App like this:

Web Monitor

Destroying the resources

Once testing has concluded and the cloud resources are no longer needed, all of them can be destroyed by simply going into the appropriate PATH where the Terraform resource files are located (in this case: /terraform) and running the Terraform command:

  terraform destroy

and typing "yes" when prompted.

Scripts Highlights

Depending on the selected Terraform scripts, they will allow you to:

  • Provision 1 Solace PS+ Software HA Cluster
  • Provision 4 Solace PS+ Cache nodes
  • Provision 1 Market Data client - MD Feed Simulators + MD Monitor Web App

List of resources to be created by Terraform:

  • SSH Key Pair to log into the VMs
  • Network VPC (If no existing subnet is specified)
  • Network Subnet, one for each HA node (If no subnet is specified)
  • Network Internet Gateway
  • Network Route Table
  • Security Group for the SDKPerf nodes
  • Security Group for the PS+ Cache & Client nodes
  • PS+ Cache Nodes, Running Ubuntu Server 24.04 LTS
  • Solace Broker Nodes, Running Ubuntu Server 24.04 LTS (HA Configured Nodes)
  • Solace Broker Data External Disk (gp2 or Premium_LRS, io1 & UltraSSD_LRS can also be provisioned if needed)
  • Ansible Inventory File containing Public & Private IPs for Solace Brokers
  • Ansible Inventory File containing Public & Private IPs for PS+ Cache nodes
  • Ansible Inventory File containing Public & Private IPs for the MD Client node
  • Resource Tags: Name, Owner, Purpose & Days (When applicable)

List of Tasks to be executed by Ansible at bootstrap:

On Solace Broker nodes:

  • Enable SWAP on the VM
  • Partition, Format & Mount external disk
  • Create & Assign permissions for the Broker folders on the external disk
  • Install Docker CE
  • Install docker-compose
  • Parse & upload docker-compose template according to the Solace Broker type (Standard, Enterprise or Enterprise Eval) & Node Role (Standalone, Primary, Backup or Monitor)
  • Copy Solace Broker Image to VM (Only for Enterprise or Enterprise Eval)
  • Load Solace Broker Image (Only for Enterprise or Enterprise Eval)
  • Create and Run Solace Docker container according to the created docker-compose file
  • Install performance monitoring tools on the OS: HTOP, sysstat (iostat)
  • Wait for SEMP to be ready
  • SEMP request to Assert Master Broker
  • SEMP request to update-broker-spoolsize
  • SEMP requests to create Solace configurations on the Solace Brokers

On PS+ Cache nodes:

  • Enable SWAP on the VM
  • Copy the PS+ Cache & Solace C API binary files to the Cache nodes
  • Configure the PS+ Cache instances to register themselves on the Solace Brokers
  • Run the PS+ Cache as systemd daemon

On Market Data Client node:

  • Enable SWAP on the VM
  • Install OpenJDK
  • Install httpd
  • Start httpd daemon
  • Copy the MDWebMonitor Web App to the /var/www/html path
  • Copy the MDFeedHandler simulator, and start 2 Exchange instances (NYSE & BMV)

Customizing the Demo

If you need to customize the PS+ Cache configurations, it can be done by modifing the following files:

Authors

See the list of contributors who participated in this project.

Resources

To tie Terraform and Ansible together, we do two things:

  • Run an Ansible playbook after the Virtual Machine has been provisioned using Terraform's "local_exec" provisioner
  • Generate inventory files from our VM instances by formatting Terraform's output

Terraform will automatically use the playbooks under /ansible/playbooks/bootstrap to set up our VM instances.

For more information try these resources:

About

Working demo that can easily demonstrate the Solace PubSub+ Cache capabilities by using terraform & ansible to automate the Infra creation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages