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 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


  • 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
    gcloud init
  • 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;


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
      export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
    2. Add the Cloud SDK distribution URI as a package source
      echo "deb $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
    3. Import the Google Cloud Platform public key
      curl | sudo apt-key add -
    4. Update the package list and install the Cloud SDK
      sudo apt-get update && sudo apt-get install google-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:
gcloud projects create PROJECT_ID
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:
gcloud projects create PROJECT_ID --organization=ORGANIZATION_ID
gcloud projects create PROJECT_ID --folder=FOLDER_ID

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:
    gcloud init
    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:
    Pick cloud project to use: 
    [1] [qspace1] 
    [2] [qspace2] 
    Please enter your numeric choice:
    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:

    Which compute zone would you like to use as project default?
    [1] [asia-east1-a]
    [2] [asia-east1-b]
    [14] Do not use default zone
    Please enter your numeric choice:
  • gcloud init confirms that you have complete the setup steps successfully:
  • gcloud has now been configured!

    You can use [gcloud config] to change more gcloud settings.
  • 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:>; Invoked manually and performs steps (B) and (C);>;Invoked by and performs step (D)
This step is performed using the following commands in script:
#create instance
gcloud compute instances create instance14 --zone us-central1-b

gcloud compute scp ~/Desktop/CloudFiles/ instance14:~/; 

#copy server
gcloud compute scp –recurse ~/Desktop/Server.tar.gz instance14:~/ 

#copy client
gcloud compute scp –recurse ~/Desktop/Client.tar.gz instance14:~/

#run on virtual machine
gcloud compute ssh –zone us-central1-b instance14 –command ‘sh ~/

Starting Client and Server

  • Unzip server binaries and change permissions
    sudo tar -zxvf Server.tar.gz chmod -R 777 *
  • check if any server process or amps is already running or not
  • If yes then stop the server
    cd Server/qspace-repo
    ps -a|egrep "ampServer|qserv|qupdate|qscen|qpk"
    if [ $? -eq 0 ]
    sudo ./script/
  • If No, then get the number of records and start the server
    echo -n "Enter the number of records:"
    read n
    sudo ./script/ $n clean
  • Verify if all the required server processes have started
    count=`ps -a|egrep "ampServer|qserv|qupdate|qscen|qpk"|wc -l`
    if [ $count -eq 5 ]
    echo "Server started successfully..."
  • Unzip the client process
    cd ../.. sudo tar -zxvf Client.tar.gz cd Client/qgraphweb
  • Install NodeJS
    echo "NPM installation..."
    curl -sL | sudo -E bash -
    sudo apt-get install -y nodejs
    npm i
    echo "NPM installation...done"
  • Change serverconfig to set appropriate server machine to which the client will be connecting to true
    sudo sed -i "s/localhost/$ip/" src/serverconfig.json
    echo $ip
  • Start client
    npm start

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 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.

      Example :
      tcp:9006, (json-tcp)
      tcp:9007, (sow-protobuf-tcp)
      tcp:9008 (websocket-any)
      tcp:9009 (fix-tcp)
      tcp:9027 (amps-any-type-tcp)
      tcp:8085 (AMPS Message Broker server page)
      Tcp:3000 (QGraph client access port)
  • 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.