Skip to content

Commit 8ff4224

Browse files
authored
Merge pull request #10 from delftdata/split-resources-kafka-topics
Cluster benchmarking
2 parents 6938f80 + 358c0b8 commit 8ff4224

11 files changed

Lines changed: 707 additions & 302 deletions

File tree

Dockerfile.pyflink

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM flink:1.20.0-scala_2.12
2+
3+
# Install Python 3.11.11
4+
RUN apt-get update && apt-get install -y \
5+
software-properties-common && \
6+
add-apt-repository ppa:deadsnakes/ppa && \
7+
apt-get update && \
8+
apt-get install -y python3.11 python3.11-venv python3.11-dev && \
9+
ln -sf /usr/bin/python3.11 /usr/bin/python && \
10+
ln -sf /usr/bin/python3.11 /usr/bin/python3 && \
11+
rm -rf /var/lib/apt/lists/*
12+
13+
# Install pip
14+
RUN python3.11 -m ensurepip --upgrade && \
15+
ln -sf /usr/local/bin/pip3 /usr/bin/pip && \
16+
ln -sf /usr/local/bin/pip3 /usr/bin/pip3
17+
18+
# Copy requirements file
19+
COPY requirements.txt /requirements.txt
20+
21+
# Install Python dependencies
22+
RUN pip install --no-cache-dir -r /requirements.txt
23+
24+
CMD ["bash"]

README.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,90 @@
11
# Cascade
22

3+
## Benchmarking
4+
5+
Requirements:
6+
- Docker
7+
- Conda
8+
- Local flink client
9+
10+
1. First create the conda environment with:
11+
12+
```
13+
conda env create -f environment.yml
14+
```
15+
16+
2. Activate the environment with:
17+
18+
```
19+
conda activate cascade_env
20+
```
21+
22+
3. Start the Kafka and Pyflink local clusters
23+
24+
```
25+
docker compose up
26+
```
27+
28+
This will launch:
29+
30+
- a Kafka broker at `localhost:9092` (`kafka:9093` for inter-docker communication!) and,
31+
- a [Kafbat UI](https://github.com/kafbat/kafka-ui) at http://localhost:8080
32+
- a local Flink cluster with `PyFlink` and all requirements, with a ui at http://localhost:8081
33+
34+
By default the flink cluster will run with 16 task slots. This can be changed
35+
setting the `TASK_SLOTS` enviroment variable, for example:
36+
37+
```
38+
TASK_SLOTS=32 docker compose up
39+
```
40+
41+
You could also scale up the number of taskmanagers, each with the same defined
42+
number of task slots (untested):
43+
44+
```
45+
docker compose up --scale taskmanager=3
46+
```
47+
48+
Once everything has started (for example, you can see the web UIs running), you
49+
can upload the benchmark job to the cluster. Note that the Kafka topics must be
50+
emptied first, otherwise the job will immediately start consuming old events.
51+
You can use the Kafbat UI for this, for example by deleting topics or purging
52+
messages. To start the job, first navigate to the cascade repo directory e.g.
53+
`cd /path/to/cascade`. Then run the following command, where `X` is the default
54+
parallelism desired:
55+
56+
```
57+
flink run --pyFiles /path/to/cascade/src,/path/to/cascade --pyModule deathstar_movie_review.demo -p X
58+
```
59+
60+
> This command runs `FlinkRuntime.init`, which requires the location of a
61+
> flink-python jarfile.
62+
> The location is currently hardcoded in `src/cascade/runtime/flink_runtime` and
63+
> should be changed based on your environment. The jar file is included as part
64+
> of the flink installation itself, at https://flink.apache.org/downloads/ (1.20.1).
65+
66+
Once the job is submitted, you can start the benchmark. Open another terminal in
67+
the same directory (and conda environment) and run:
68+
69+
```
70+
python -m deathstar_movie_review.start_benchmark
71+
```
72+
73+
This will start the benchmark by sending events to Kafka. The first phase will
74+
initialise the state required for the benchmark, and is not measured. The second
75+
phase starts the actual becnhmark.
76+
77+
78+
### Notes
79+
80+
Currently trying to scale up higher than `-p 16`, however I ran into the
81+
following issue on `-p 64` with `TASK_SLOTS=128`, more configuration might be required?
82+
83+
```
84+
Caused by: java.io.IOException: Insufficient number of network buffers: required 65, but only 38 available. The total number of network buffers is currently set to 4096 of 32768 bytes each. You can increase this number by setting the configuration keys 'taskmanager.memory.network.fraction', 'taskmanager.memory.network.min', and 'taskmanager.memory.network.max'.
85+
```
86+
87+
388
## Development
489

590
Cascade should work with Python 3.10 / 3.11 although other versions could work. Dependencies should first be installed with:
@@ -8,7 +93,7 @@ Cascade should work with Python 3.10 / 3.11 although other versions could work.
893
pip install -r requirements.txt
994
```
1095

11-
## Testing
96+
## (old) Testing
1297

1398
The `pip install` command should have installed a suitable version of `pytest`.
1499

0 commit comments

Comments
 (0)