Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-768

Direct buffer memory exhaustion due to slow websocket consumer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.0.0.Beta1, 1.4.0.Final
    • 1.3.22.Final
    • None
    • None

    Description

      I had a slow consumer on a websocket connection.

      The consumer's TCP buffer was full, and the connection was advertising a zero window. Attempts to flush data would result in zero bytes written.

      Every time my application would send a new message, it would call flush, which results in a call to AbstractFramedChannel.flushSenders. As part of its work, it constructs the frame header, which allocates a new buffer from the buffer pool.

      Following the defaults in the io.undertow.Undertow class, my pool is of 4k direct buffers, no maximum size.

      The slow consumer will cause new allocations of 4k from the pool in order to satisfy the < 32byte header construction.

      This eventually exhausted all available direct buffer memory until the slow consumer disconnected.

      One simple patch might be for AbstractFramedChannel.flushSenders to recognize that it is waiting for writes to be ready and to leave new frames in the newFrames collection. A cap on the number of frames to flush at once might also be useful (if it were possible to cap it from a size standpoint so more isn't prepped than necessary)

      Attachments

        Activity

          People

            sdouglas1@redhat.com Stuart Douglas
            proyal_jira peter royal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: