Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gerrit Alexander Simon Evers
Verteilte Systeme Projekt
Commits
8c846dc8
Commit
8c846dc8
authored
Feb 09, 2021
by
Andre Blanke
Browse files
Enable all three worker servers
parent
f4b53150
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
8c846dc8
# Distributed Systems project: A URL shortener
# Distributed Systems project: A
simple
URL shortener
## Table of contents
-
[
Project structure
](
#project-structure
)
-
[
Overview
](
#overview
)
-
[
Deployment
](
#deployment
)
-
[
Getting started
](
#getting-started
)
-
[
Introducing further workers
](
#introducing-further-workers
)
-
[
API
](
#api
)
## Project structure
...
...
@@ -21,6 +23,7 @@
│ │ └─ worker/files/
│ │ └─ systemd/system/
│ │ ├─ cockroach.service.d/override.conf
│ │ ├─ memcached.service.d/override.conf
│ │ └─ shortener.service # systemd service to start the URL shortener
│ ├─ frontend.yml
│ └─ worker.yml
...
...
@@ -65,25 +68,41 @@ The project is currently deployed using an embedded Tomcat instance, the default
by Spring Boot, which serves both static files and handles API requests.
Requests are handled on one of the workers picked by HAProxy which is running on the frontend server.
##
Introducing further workers
##
Getting started
Currently three worker servers are used with each one running one instance of our backend application,
an
Apache HTTP Server
instance
and a
CockroachDB node.
an
embedded Tomcat
instance
,
CockroachDB node
, and a memcached server
.
At the present time some configuration files need to be edited in order to introduce further workers.
The workers are automatically assigned an IP address of the form
`192.168.10.(10 + N)`
where
`N`
is
the index of the worker starting with 1.
the index of the worker starting with 1. Their names follow a similar scheme, namely
`worker-N`
.
The IP address
`192.168.10.10`
is reserved for the frontend server responsible for running the load
balancer and initializing the CockroachDB database cluster at provision time.
balancer which redirects requests to one of the background workers.
Simply running
`vagrant up`
should get you started. The process brings up the workers first followed
by the frontend server, the latter of which initializes the CockroachDB cluster.
Once all virtual machines have been started the frontend should be reachable under
[
192.168.10.10
](
http://192.168.10.10
)
.
### Introducing further workers
At the present time some configuration files need to be edited in order to introduce further workers.
The following files currently need to be changed when one wants to add or remove a worker:
-
The
`num_workers`
variable in
`Vagrantfile`
-
The
`haproxy.cfg`
file located at
`/ansible/roles/frontend/files/haproxy/haproxy.cfg`
-
`/ansible/roles/worker/files/systemd/system/cockroach.service.d/override.conf`
-
The
`num_workers`
variable in
`Vagrantfile`
in order to add more worker virtual machines
-
The
`haproxy.cfg`
file located at
`/ansible/roles/frontend/files/haproxy/haproxy.cfg`
, to make allow
the additional worker servers to be reachable from the frontend server's load balancer
-
`/ansible/roles/worker/files/systemd/system/cockroach.service.d/override.conf`
to add the additional
CockroachDB instances on the new workers to the cluster
-
`/ansible/roles/worker/files/systemd/system/shortener.conf`
to add the additional memcached instances
on the new workers to be reachable from all the clients
Both of the latter two files should be changed at some point to make use of Ansible's templating
feature so that only
`num_workers`
has to be edited, at least this should be possible.
All of the files named above except for the
`Vagrantfile`
should be changed at some point to make
use of Ansible's templating feature so that only
`num_workers`
has to be edited, at least this
should be possible.
## API
...
...
ansible/roles/frontend/files/haproxy/haproxy.cfg
View file @
8c846dc8
...
...
@@ -4,5 +4,5 @@ frontend main
backend workers
server worker-1 192.168.10.11:8080 check
#
server worker-2 192.168.10.12:8080 check
#
server worker-3 192.168.10.13:8080 check
server worker-2 192.168.10.12:8080 check
server worker-3 192.168.10.13:8080 check
ansible/roles/worker/files/systemd/system/shortener.service
View file @
8c846dc8
...
...
@@ -2,7 +2,7 @@
Description
=
upbshrt.xyz backend
[Service]
Environment
=
MEMCACHED_CLIENTS="192.168.10.11:11211"
Environment
=
MEMCACHED_CLIENTS="192.168.10.11:11211
192.168.10.12:11211 192.168.10.13:11211
"
ExecStart
=
/usr/bin/java -jar /opt/shortener/shortener.jar
[Install]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment