Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-5500

Portable python sdk worker leaks memory in streaming mode

Details

    Description

      When using the portable python sdk with flink in streaming mode, we see that the python worker processes steadily increase memory usage until they are OOM killed. This behavior is consistent across various kinds of streaming pipelines, including those with fixed windows and global windows.

      A simple wordcount-like pipeline demonstrates the issue for us (note this is run on the Lyft beam fork, which provides access to kinesis as a portable streaming source):

      counts = (p
      | 'Kinesis' >> FlinkKinesisInput().with_stream('test-stream')
      | 'decode' >> beam.FlatMap(decode) # parses from json into python objs
      | 'pair_with_one' >> beam.Map(lambda x: (x["event_name"], 1))
      | 'window' >> beam.WindowInto(window.GlobalWindows(),
                                    trigger=AfterProcessingTime(15 * 1000),
                                    accumulation_mode=AccumulationMode.DISCARDING)
      | 'group' >> beam.GroupByKey()
      | 'count' >> beam.Map(count_ones)
      | beam.Map(lambda x: logging.warn("count: %s", str(x)) or x))
      
      

      When run, we see a steady increase in memory usage in the sdk_worker process. Using heapy I've analyzed the memory usage over time and found that it's largely dicts and strings (see attached chart).

       

       

       

      Attachments

        1. chart.png
          21 kB
          Micah Wylde

        Issue Links

          Activity

            People

              robertwb Robert Bradshaw
              mwylde Micah Wylde
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h