[ 
https://issues.apache.org/jira/browse/JAMES-4093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Benoit Tellier updated JAMES-4093:
----------------------------------
    Description: 
h2. Why?

Several goals:

 - Have tools to ensure fairness across users
 - Have tools to prevent / mitigate network saturation

This could help mitigating DOS, throttling painfull migrations in order to 
protect the underlying on-prem object store, etc...

h2. What ?

As an IMAP administrator I want to be able to set up optional Traffic shapping 
for IMAP, stating that for instance I limit each IMAP channel to a 1MB/s 
bandwith.

Example configuration:


{code:java}
<imapserver enabled="true">
    <jmxName>imapserver</jmxName>
    <bind>0.0.0.0:0</bind>
    <connectionBacklog>200</connectionBacklog>
    <trafficShapping>
        <incomingTrafficPerSecond>5MB</incomingTrafficPerSecond>
        <outgoingTrafficPerSecond>5MB</incomingTrafficPerSecond>
        <checkInterval>30s</checkInterval>
        <maxDelays>30s</maxDelays>
    </trafficShapping>
</imapserver>
{code}

h2. How?

Netty provides out of the box traffic shapping.

Just insert ChannelTrafficShapingHandler part of the pipeline.

CF 
https://netty.io/4.0/api/io/netty/handler/traffic/ChannelTrafficShapingHandler.html

h2. Kisscool benefits

Note that we might even be able to access traffic metrics and augment 
JAMES-4091 !

{code:java}
curl -XGET /servers/channels/btell...@apache.org
[
   {
       "protocol": "IMAP",
        "endpoint": "imap-ssl",
        "encrypted": true, // SSLHandler part of the pipeline
        "connectionDate": "2024-11-20T16:00:00Z", // Tracked via an attribute 
to set upon connection
        "remoteAddress": "12.23.45.43:4378",
        "isActive": true,
        "username": "btell...@apache.org",
        "protocolSpecificInformation": {
             "userAgent": "outlook",
             "compressed": "true", // CompressHandler part of the pipeline
             "cumulativeWrittenBytes": "3357352863", 
             "cumulativeReadBytes": "2442343434", 
             "liveReadThroughputBytePerSecond": "345678", 
             "liveWriteThroughputBytePerSecond": "344564", 
             "lastRead": "2024-11-20T16:05:00Z", 
             "lastWrite": "2024-11-20T16:07:00Z", 
             "cumulativeReadBytes": "2442343434", 
             "selectedMailbox": "INBOX", // Read the IMAPSession
             "isIdling": "true",  // Inspect behavious in protocol overrides
         }   
   },
...
]
{code}

(channel.pipeline().get(TEFFIC_SHAPPER).trafficCounter())


  was:
h2. Why?

Several goals:

 - Have tools to ensure fairness across users
 - Have tools to prevent / mitigate network saturation

This could help mitigating DOS, throttling painfull migrations in order to 
protect the underlying on-prem object store, etc...

h2. What ?

As an IMAP administrator I want to be able to set up optional Traffic shapping 
for IMAP, stating that for instance I limit each IMAP channel to a 1MB/s 
bandwith.

Example configuration:


{code:java}
<imapserver enabled="true">
    <jmxName>imapserver</jmxName>
    <bind>0.0.0.0:0</bind>
    <connectionBacklog>200</connectionBacklog>
    <trafficShapping>
        <incomingTrafficPerSecond>5MB</incomingTrafficPerSecond>
        <outgoingTrafficPerSecond>5MB</incomingTrafficPerSecond>
        <checkInterval>30s</checkInterval>
        <maxDelays>30s</maxDelays>
    </trafficShapping>
</imapserver>
{code}

h2. How?

Netty provides out of the box traffic shapping.

Just insert ChannelTrafficShapingHandler part of the pipeline.

CF 
https://netty.io/4.0/api/io/netty/handler/traffic/ChannelTrafficShapingHandler.html

h2. Kisscool benefits

Note that we might even be able to access traffic metrics and augment 
JAMES-4091 !

{code:java}
curl -XGET /servers/channels/btell...@apache.org
[
   {
       "protocol": "IMAP",
        "endpoint": "imap-ssl",
        "encrypted": true, // SSLHandler part of the pipeline
        "connectionDate": "2024-11-20T16:00:00Z", // Tracked via an attribute 
to set upon connection
        "remoteAddress": "12.23.45.43:4378",
        "isActive": true,
        "username": "btell...@apache.org",
        "protocolSpecificInformation": {
             "compressed": "true", // CompressHandler part of the pipeline
             "cumulativeWrittenBytes": "3357352863", 
             "cumulativeReadBytes": "2442343434", 
             "liveReadThroughputBytePerSecond": "345678", 
             "liveWriteThroughputBytePerSecond": "344564", 
             "lastRead": "2024-11-20T16:05:00Z", 
             "lastWrite": "2024-11-20T16:07:00Z", 
             "cumulativeReadBytes": "2442343434", 
             "selectedMailbox": "INBOX", // Read the IMAPSession
             "isIdling": "true",  // Inspect behavious in protocol overrides
         }   
   },
...
]
{code}

(channel.pipeline().get(TEFFIC_SHAPPER).trafficCounter())



> IMAP: Basic traffic control
> ---------------------------
>
>                 Key: JAMES-4093
>                 URL: https://issues.apache.org/jira/browse/JAMES-4093
>             Project: James Server
>          Issue Type: New Feature
>            Reporter: Benoit Tellier
>            Priority: Major
>
> h2. Why?
> Several goals:
>  - Have tools to ensure fairness across users
>  - Have tools to prevent / mitigate network saturation
> This could help mitigating DOS, throttling painfull migrations in order to 
> protect the underlying on-prem object store, etc...
> h2. What ?
> As an IMAP administrator I want to be able to set up optional Traffic 
> shapping for IMAP, stating that for instance I limit each IMAP channel to a 
> 1MB/s bandwith.
> Example configuration:
> {code:java}
> <imapserver enabled="true">
>     <jmxName>imapserver</jmxName>
>     <bind>0.0.0.0:0</bind>
>     <connectionBacklog>200</connectionBacklog>
>     <trafficShapping>
>         <incomingTrafficPerSecond>5MB</incomingTrafficPerSecond>
>         <outgoingTrafficPerSecond>5MB</incomingTrafficPerSecond>
>         <checkInterval>30s</checkInterval>
>         <maxDelays>30s</maxDelays>
>     </trafficShapping>
> </imapserver>
> {code}
> h2. How?
> Netty provides out of the box traffic shapping.
> Just insert ChannelTrafficShapingHandler part of the pipeline.
> CF 
> https://netty.io/4.0/api/io/netty/handler/traffic/ChannelTrafficShapingHandler.html
> h2. Kisscool benefits
> Note that we might even be able to access traffic metrics and augment 
> JAMES-4091 !
> {code:java}
> curl -XGET /servers/channels/btell...@apache.org
> [
>    {
>        "protocol": "IMAP",
>         "endpoint": "imap-ssl",
>         "encrypted": true, // SSLHandler part of the pipeline
>         "connectionDate": "2024-11-20T16:00:00Z", // Tracked via an attribute 
> to set upon connection
>         "remoteAddress": "12.23.45.43:4378",
>         "isActive": true,
>         "username": "btell...@apache.org",
>         "protocolSpecificInformation": {
>              "userAgent": "outlook",
>              "compressed": "true", // CompressHandler part of the pipeline
>              "cumulativeWrittenBytes": "3357352863", 
>              "cumulativeReadBytes": "2442343434", 
>              "liveReadThroughputBytePerSecond": "345678", 
>              "liveWriteThroughputBytePerSecond": "344564", 
>              "lastRead": "2024-11-20T16:05:00Z", 
>              "lastWrite": "2024-11-20T16:07:00Z", 
>              "cumulativeReadBytes": "2442343434", 
>              "selectedMailbox": "INBOX", // Read the IMAPSession
>              "isIdling": "true",  // Inspect behavious in protocol overrides
>          }   
>    },
> ...
> ]
> {code}
> (channel.pipeline().get(TEFFIC_SHAPPER).trafficCounter())



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to