Deploy QGraph Client and QSpace Server on Google Cloud

Run Web Client and Server on Google Cloud

Cloud computing boasts several attractive benefits for businesses and end users.
The purpose of this post is to deploy QSpace server and QGraph client in to the cloud, steps covered
  • Install google cloud on the PC/Linux
  • Creation of virtual machine on Google cloud
  • Use gcloud to copy client, server and script.sh file on the virtual machine
  • Run client and server on virtual machine

Google Cloud SDK(gcloud)

Command-line interface for Cloud Platform products and services gcloud is a tool that provides the primary command-line interface to Google Cloud Platform. You can use this tool to perform many common platform tasks either from the command-line or in scripts and other automations. gcloud manages authentication, local configuration, developer workflow, and interactions with the Cloud Platform APIs. Google Compute Engine offers high performance virtual machines, customer-friendly pricing, fast networking, and carbon-neutral impact.

Google Cloud SDK Install

(Windows)

  • Download the Google Cloud SDK installer.
  • Launch the installer and follow the prompts.
  • After installation has completed, the installer presents several options:
  • Make sure that the following are selected:
    Start Google Cloud SDK Shell
  • The installer then starts a terminal window and runs the gcloud init command.
    Troubleshooting tip:If your installation is unsuccessful due to the find command not being recognized, ensure your PATH environment variable is set to include the folder containing find. Usually, this is C:\WINDOWS\system32;

(Linux):

Make sure that your operating system is one of the following:
  • Ubuntu release that has not reached end-of-life
  • Debian stable release from Wheezy forward
    Then, perform the following steps:
    1. Create environment variable for correct distribution
    2. Add the Cloud SDK distribution URI as a package source
    3. Import the Google Cloud Platform public key
    4. Update the package list and install the Cloud SDK

Creating your google cloud project

To create a project, you must have the resourcemanager.projects.create permission. When an organization is created, the entire domain has the Project Creator role, which includes that permission.
To create a new project:
  • Go to the Manage resources page in the GCP Console.
  • On the Select organization drop-down list at the top of the page, select the organization in which you want to create a project.
  • Click Create Project.
  • In the New Project window that appears, enter a project name and select a billing account as applicable.
  • If you want to add the project to a folder, enter the folder name in the Location box.
  • When you’re finished entering new project details, click Create. Both the project ID and project number are displayed on the project Dashboard Project info card:
To create a new project, using the gcloud projects create command:
Where PROJECT_ID is the ID for the project you want to create. A project ID must start with a lowercase letter, and can contain only ASCII letters, digits, and hyphens, and must be between 6 and 30 characters.
To create a project with an organization or a folder as parent, use the –organization or –folder flags. As a resource can only have one parent, only one of these flags can be used:

Initialize the SDK

Use the gcloud init command to perform several common SDK setup tasks. These include authorizing the SDK tools to access Google Cloud Platform using your user account credentials and setting up the default SDK configuration.
To initialize the SDK:
  • Run the following at a command prompt:
    Note: To prevent the command from launching a web browser, use gcloud init –console-only instead. To authorize without a web browser and non-interactively, create a service account with the appropriate scopes using the Google Cloud Platform Console and use gcloud auth activate-service-account with the corresponding JSON key file.
  • Accept the option to log in using your Google user account:
  • To continue, you must log in. Would you like to log in (Y/n)? Y
  • In your browser, log in to your Google user account when prompted and click Allow to grant permission to access Google Cloud Platform resources.
  • At the command prompt, select a Cloud Platform project from the list of those where you have Owner, Editor or Viewer permissions:
    If you only have one project, gcloud init selects it for you.
  • If you have the Google Compute Engine API enabled, gcloud init allows you to choose a default Compute Engine zone:

  • gcloud init confirms that you have complete the setup steps successfully:
  • gcloud has now been configured!

  • Your active configuration is: [default]

Copying Client and Server

QSpace is a high-performance position keeping system that combines start of the day positions with intraday trading activity to produce up to date positions that can be subscribed to by a multitude of clients. QGraph is a reactJS based client which subscribes to QSpace Server to display position and risk data.
To run qgraph client and qspace server on cloud instance we use 2 scripts:
This step is performed using the following commands in test.sh script:

Starting Client and Server

  • Unzip server binaries and change permissions
  • check if any server process or amps is already running or not
  • If yes then stop the server
  • If No, then get the number of records and start the server
  • Verify if all the required server processes have started
  • Unzip the client process
  • Install NodeJS
  • Change serverconfig to set appropriate server machine to which the client will be connecting to true
  • Start client

gCloud Firewall Rules

QSpace uses ports 9006, 9007, 9008, 9009, 9027 and 8085 to communicate with the external world.
  • Go to the Firewall rules page in the Google Cloud Platform Console.
  • Go to the Firewall rules page
  • Click Create firewall rule.
  • Enter a Name for the firewall rule.
  • This name must be unique for the project.
  • Specify the Network where the firewall rule will be implemented.
  • Specify the Priority of the rule.
  • The lower the number, the higher the priority.
  • For the Direction of traffic, choose ingress.
  • For the Action on match, choose allow or deny.
  • Specify the Targets of the rule.
    1. If you want the rule to apply to all instances in the network, choose All instances in the network.
    2. If you want the rule to apply to select instances by network (target) tags, choose Specified target tags, then type the tags to which the rule should apply into the Target tags field.
  • For an ingress rule, specify the Source filter:
    1. Choose IP ranges and type the CIDR blocks into the Source IP ranges field to define the source for incoming traffic by IP address ranges. Use 0.0.0.0/0 for a source from any network.
    2. Specify a Second source filter if desired. Secondary source filters cannot use the same filter criteria as the primary one.
  • Define the Protocols and ports to which the rule will apply:
    1. Choose Allow all or Deny all, depending on the action, to have the rule apply to all protocols and ports.
    2. Choose Specified protocols and ports then type a list of protocols and port numbers.

  • Click Create.

QGraph access

  • Open the file at /src/serverconfig.json in Client folder
  • Change the active property to true for the server(Public IP of the instance) that you may want to connect. Ensure that for all other servers the active property is set to false.

Related Posts

Leave a Comment

Comment moderation is enabled. Your comment may take some time to appear.