apache / apache/beam

[Bug]: Difficult to write Go SDK pipelines that stay within memory constraints

Open
#21,817 6 comments 0 reactions 0 assignees View on GitHub
bug go P2 performance
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

### What happened?

I am not a beam developer, just a user.

I wrote a Beam pipeline to download zip files over HTTP and write them to disk in a record-oriented format (Riegeli).

- The direct runner stores everything in memory, so it has no hope of avoiding OOM. That's fine, I guess.
- Even with Flink, I can't seem to avoid running out of memory. I have 35 GB free at beginning of execution. By the end, I have 1% or 0% free. The Go process eventually dies after getting up to ~7GB of consumption, while Flink is presumably consuming the rest.

Would it be possible to do something crude like return "Resource exhausted" codes from the Go harness after a certain memory threshold is reached? Would the Flink runner be smart enough to reduce the request rate and memory pressure?

![memory graph part 1](https://user-images.githubusercontent.com/83831/173274653-2f91cf76-5601-43e4-877d-dad65e5f7b6c.png)

![memory graph part 2](https://user-images.githubusercontent.com/83831/173274666-e0e7dfaf-bee2-4dc3-83cc-12628de3929f.png)

![memory profile](https://user-images.githubusercontent.com/83831/173274566-2075cfa0-e1e0-4c70-9215-920f87efd85d.png)

Launch commands:

Beam pipeline:

```shell
bazel run //:download_stuff -- --runner flink --endpoint localhost:8099 "--output_riegeli" "/tmp/map_output@20.riegeli" "--environment_type" "LOOPBACK" --alsologtostderr --beam_strict
```

I can create a repo with a reproduction if the authors think that would be useful.

Flink
```shell
bazel run :job -- "--flink-conf-dir" /home/red/flink/
```

Where :job is defined by

```starlark
java_binary(
name = "job",
main_class = "org.apache.beam.runners.flink.FlinkJobServerDriver",
runtime_deps = [
# Obtained by looking at results of
# bazel query @maven//...
"@maven//:org_apache_beam_beam_runners_flink_1_14",
"@maven//:org_slf4j_slf4j_api",
"@maven//:org_slf4j_slf4j_simple",
"@maven//:org_apache_flink_flink_runtime_web_2_12",
],
)
```

See my [flink-conf.yaml gist](https://gist.github.com/gonzojive/6a5e32dbc5693770cfd07624f8c55bee) for how Flink is configured.

### Issue Priority

Priority: 2

### Issue Component

Component: sdk-go

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.