[Bug]: Difficult to write Go SDK pipelines that stay within memory constraints
- 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?



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
Assessment
This issue has not been assessed yet.