In this exercise, we will create an Alloy DB instance, and compare its performance with a PostgreSQL instance.
-
Go to the GCP Console, search Alloy DB and create a new Alloy DB instance.
-
In the ID cluster put
alloy-db-<edem-user>
-
In Password put
EDEM2425
-
In the region, select
europe-southwest1 (Madrid)
-
In the network, select
default
-
In the machine type select
4 vCPUs, 32 GB RAM
-
Allow the IP public access
-
In the security of the network, sellect
Allow all connection without encryption
-
Click on
Create
After the instance is created (it will take a few minutes to be ready), we can move to the python script part
-
First you should create a venv and install the requirements
-
Then you have to modify the IP variable of the alloy.py script to put the IP of your Alloy DB instance
-
Run the script with
python alloy.py
-
To test it against a PostgreSQL instance, you can run the script
python postgresql.py
modifying the IP variable to the IP of your PostgreSQL instance -
Once both scripts are run, you can log in both Cloud SQL Studio and Alloy DB Studio to check the performance of both instances
-
Run this query in both Studios:
SELECT c.currency_code, er.base_currency_code, er.rate, er.timestamp FROM exchange_rates er LEFT JOIN currencies c ON c.id = er.currency_id