prj2 (1)
pdf
keyboard_arrow_up
School
University of Southern Maine *
*We aren’t endorsed by this school
Course
473
Subject
Information Systems
Date
Dec 6, 2023
Type
Pages
6
Uploaded by EarlFreedom7102
Project 2 Report
Answers to questions in Section II:
1. What is the license of the original example code from the textbook? (Hint: read the
'LICENSE' file)
The original example code from the textbook is licensed under the Apache License,
Version 2.0.
2. Open source software may use other licenses like GNU General Public License (GNU
GPL) and GNU Affero General Public License (GNU AGPL). What are the difference
between GNU GPL and GNU AGPL for cloud services?
The GNU GPL and the GNU AGPL both incorporate a copyleft provision, which means
that if you modify and distribute software licensed under these licenses, you are required to
make the source code of those modifications available to others. This ensures that any
improvements or changes to the software remain open source and accessible.
One of the key distinctions between the two licenses is their treatment of cloud services:
The GNU GPL is well-suited for applications that are not delivered over a network. It is
commonly used for traditional software that is run on individual computers or servers but is not
primarily accessed as a service over the internet. The GPL does not have explicit provisions
addressing the use of software over a network, such as in cloud services.
In contrast, the AGPL was created with a specific focus on web applications, cloud
services, and software delivered over a network. It closes a perceived "loophole" in the GPL by
requiring that if you modify AGPL-licensed software and use it to provide a service over the
internet, you must make the source code of those modifications available to users who interact
with the service over the network. This ensures that the open-source nature of the software is
preserved even in the context of cloud-based applications.
3. The kvs service depends on the postgres service as it need to load the transaction log
from the database. The dependency is defined in docker-compose.yml so that postgres
starts before kvs. However, the log messages above indicate that kvs still need to retry
connecting to postgres. Why?
The KVS service is retrying connecting to the Postgres service because Postgres, upon
startup, needs to go through all previous transactions to reach the current state of the database.
This process may take some time, causing KVS to attempt connections before Postgres is fully
ready. To address this, ensure that you implement proper service initialization and readiness
checks in your Docker containers to confirm that Postgres is fully operational before allowing
other services to connect.
III. Manageability via Environment Variables
In the provided screenshot, I made changes to the service.go file, specifically within the
initializeTransactionLog() function. I updated the code where a NewPostgresTransactionLogger
is created, replacing the plain text values for dbName, user, and password with references to
environment variables that are retrieved from the docker-compose.yml file.
In the provided screenshot of the docker-compose.yml file, I introduced environment
variables within the kvs section. These environment variables are set to be recognized by the
KVS container. Specifically, the user, password, and db values are now represented as
environment variables, which the service.go function accesses when needed.
In the screenshot provided, I documented the process of rebuilding and recreating the
two containers after making modifications to both the service.go and docker-compose.yml files.
This process involved executing two commands: "docker compose build" to rebuild the
containers and "docker compose create" to create them again. Subsequently, I initiated the
containers using the "docker compose start" command. To ensure that both containers were
successfully started and running, I employed the "docker ps -a" command to verify their status.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Next, I checked if the connection was working by using the "curl" command for both
"PUT" and "GET" operations on values "a," "b," and "c." These tests were successful, as you
can see in the screenshot I provided.
Lastly, I looked at the logs of the container with the CONTAINER ID that begins with
"458" (named "ece473-prj02-kvs-1"). These logs showed multiple instances of "GET" and "PUT"
actions, which matched the actions I performed using the "curl" commands as shown in my
screenshots above.
IV. (Bonus) Fault Tolerance Testing
KVS shutdown
Postgres shutdown
1. Is there any data loss if one service is down? Why?
For the KVS test, I first added a data entry "test a" into the database. Then, I intentionally
stopped the KVS service and started it again. Surprisingly, I could still retrieve "test a" using the
GET method after the restart. This means no data was lost during this process.
Now, for the Postgres test, I did it in two parts. In the first part, I added a key-value pair
"bonus a" when the Postgres service was offline. After restarting the Postgres service, I could
still see "bonus a," which means it didn't get lost.
However, in the second part, I stopped and then restarted the KVS service immediately
after adding "bonus b." This time, when I tried to retrieve "bonus b" using the GET method, it
didn't work and I got a "no such key" response.
The reason behind this seems to be that when I initially added "bonus b" while the
Postgres service was down, the KVS stored this change in its local memory, not the Postgres
database. So, when the Postgres service came back online, it read from the KVS's memory, but
it didn't update its own database. But when I shut down and restarted the KVS service, it seems
to have cleared its memory, causing the "bonus b" entry to be lost.
In simple terms, the KVS temporarily saved "bonus b" when the Postgres was down, but
when I restarted the KVS, it forgot about it, and Postgres didn't catch up. That's why I couldn't
retrieve "bonus b" later.
2. If there is, what would you like to do?
To handle a scenario like this, it's essential to establish synchronization between the
cache of the KVS service and the Postgres database. This way, if either service experiences
downtime, there would be a backup process in place to ensure that both services stay aligned.
This backup process would facilitate the synchronization of all transaction logs stored in the
cache with the main database.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help