You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
@@ -11,9 +11,14 @@ It also provides dozens of virtual environments, accessible with a few clicks, t
11
11
The purpose of this project is to provide an API to use
12
12
[Root-Me](https://www.root-me.org/?lang=en) data, provide a discord bot fetching events and data from this API and to build a distributed system thanks to workers using [redis streams and consumer groups](https://redis.io/topics/streams-intro).
13
13
14
+
Using different worker instances is necessary to increase performance because
15
+
Root-Me website is blocking the requests if it detects too much connections
16
+
incoming from a specific public IP (You get an HTTP error code: "429 Too Many Requests"). \
17
+
(See advanced configuration).
18
+
14
19
## How does it works ?
15
20
16
-
When a client is making a request on the API, the server is checking if there is an existing data in an associated [redis key](https://redis.io/commands/getset). If not, the server is sending a task to workers through the appropriate [redis stream](https://redis.io/topics/streams-intro). If there is existing data, the API is checking if the last update is not too old (depends on `UPDATE_TIMEOUT` in [constants.py](https://github.com/zteeed/Root-Me-API/blob/master/api/api/constants.py)) and ask the workers for updates if necessary.
21
+
When a client is making a request on the API, the server is checking if there is existing data in an associated [redis key](https://redis.io/commands/getset). If not, the server is sending a task to workers through the appropriate [redis stream](https://redis.io/topics/streams-intro). If there is existing data, the API is checking if the last update is not too old (depends on `UPDATE_TIMEOUT` in [constants.py](https://github.com/zteeed/Root-Me-API/blob/master/api/api/constants.py)) and ask the workers for updates if necessary.
17
22
18
23
The form of the data is:
19
24
@@ -45,15 +50,104 @@ You need to create a discord bot here: [https://discordapp.com/developers/applic
45
50
46
51
## Advanced configuration (1+ workers)
47
52
53
+
- You can expose your redis by adding to redis service `docker-compose.yml`:
54
+
```
55
+
ports:
56
+
- 6379:6379
57
+
```
58
+
- If you want to deploy several workers you might need to modify [worker/main.py](https://github.com/zteeed/Root-Me-API/blob/master/worker/main.py), using the public ip where you deploy the redis container.
You might need the attributes from the [docker macvlan network](https://docs.docker.com/network/macvlan/).
74
+
75
+
76
+
2. Details
77
+
78
+
This configuration avoids interfaces from backend network to get an access to internet, but we
79
+
want containers from this network to communicate together (api/redis/workers).
80
+
81
+
Every worker is bridged with a specific physical interface so that Root-Me detects those workers with different public IP. \ (We choose not to [rotate with proxies](https://www.scrapehero.com/how-to-rotate-proxies-and-ip-addresses-using-python-3/) for data privacy issues).
82
+
83
+
*__Example__* (extract from [advanced_configuration/docker-compose.yml](https://github.com/zteeed/Root-Me-API/blob/master/advanced_configuration/docker-compose.yml):
84
+
```
85
+
bridge_worker:
86
+
driver: macvlan
87
+
driver_opts:
88
+
parent: eth1
89
+
macvlan_mode: bridge
90
+
ipam:
91
+
config:
92
+
- subnet: 157.159.191.0/24
93
+
gateway: 157.159.191.2
94
+
ip_range: 157.159.191.56/29
95
+
```
96
+
97
+
If you deploy 6 workers (see "Install" subsection), the workers will take
98
+
`157.159.191.56-61` as IPv4 address thanks to `ip_range` attribute (those are
99
+
taken in ascending order in the subnet specified).
100
+
101
+
> Communication with the Docker host over macvlan.
102
+
> When using macvlan, you cannot ping or communicate with the default namespace IP address. For example, if you create a container and try to ping the Docker host’s eth0, it will not work. That traffic is explicitly filtered by the kernel modules themselves to offer additional provider isolation and security.
0 commit comments