vy commented on issue #335: Import of LogstashLayout as JsonTemplateLayout
URL: https://github.com/apache/logging-log4j2/pull/335#issuecomment-580267355
 
 
   > Not sure I agree... What is the trade-off? What do users gain when they 
select something other than ThreadLocal?
   
   If you'd recall, we had this discussion in the mailing list in 
[December](http://mail-archives.apache.org/mod_mbox/logging-dev/201912.mbox/%3CCAP7pH7sHb-nP8iGJybruCkno1FzajrO8PSUBPCOAkpZP2dNYvA%40mail.gmail.com%3E)
 and 
[January](http://mail-archives.apache.org/mod_mbox/logging-dev/202001.mbox/%3CCACmp6koucj6N2%3DFW_xM4sX2ZCLdYkHZSs9535NYjfY5wtWiLGQ%40mail.gmail.com%3E).
 There the raised concern was TLAs, in particular, in the domain of web 
applications where there is a proliferation of threads and 
`AbstractStringLayout`, used by many `String`-emitting layouts, is not taking 
`log4j2.enableThreadlocals` flag into account, etc.
   
   As described in [this 
ticket](/vy/log4j2-logstash-layout/issues/50#issuecomment-574671508), 
`JsonTemplateLayout` has a memory footprint which can be summarized with the 
following rough formula:
   
   ```
   threadCount * (
       (stackTraceEnabled ? 1 : 0) * maxByteCount +    // for stacktraces
       maxByteCount +    // for JSON
       epsilon    // for the rest (<100 bytes)
   )
   ```
   
   While this is a perfectly affordable footprint where the thread count 
matches the available CPU cores, it is not something desirable in a (web) 
application container. My suggestion is to leave this decision to user (granted 
we incorporate sane defaults) and support each strategy. Is this a slick 
Netty/gRPC app? Stick to TLAs. Is this an app running on Tomcat? Stick to 
pooling. Is this an embedded app with relatively low load? Stick to allocation.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to