You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Dima Retov <di...@axisway.com> on 2007/10/18 09:18:10 UTC

Re[2]: James too many threads

Thank you.

Actually I had 150 threads and now I have 54.
(I have decreased max-connections from 10 to 3)

I have min-threads 1 and spare threads 2.
(I think this must decrease allocated threads to 1 thread when they
are not used)

RemoteDelivery and remotemaneger were already set 1 thread.

I have smtp, smtps and pop3s services.
I am the only user who uses smtps and pop3s. So I guess it must
allocate 1 thread per smtps and pop3s if I do not read or sent emails
for some time.


-- 
Best regards,
 Dima                            mailto:dima@axisway.com


Wednesday, October 17, 2007, 12:03:08 PM, you wrote:

SB> Dima Retov ha scritto:
>> Hello,
>> 
>> I have James running on my server and it works fine.
>> I handles emails for dozen of domain. I receive few emails per day.
>> I would like to configure James to consume less resources.
>> 
>> When I start James now it starts with 30 or 50 threads.
>> 
>> I would like to keep 1 or 3 threads.

SB> You will not able to reduce the number so much. But you can limit it a
SB> lot, anyway.

>> I tried to tune max-connections and max-thread and I had 2 results
>> james was not starting or james was running with same amount of
>> threads.
>> 
>> 
>> It is possible to decrease number of threads?
>> How do I do that?

SB> First you have to reduce the number of <spoolmanager>/<threads>, the
SB> number of RemoteDelivery/<deliveryThreads>, and you have to reduce the
SB> number <connections>/<max-connections>30</max-connections>.

SB> As the last step you can tune your
SB> <thread-manager>/<thread-group>/<max-threads> so that max-threads is at
SB> least
SB> spoolmanagerthreads+remotedeliverythreads+maxconnections*services
SB> (services is pop3+smtp+ any other listening service you may have)

SB> If you really have few incoming connections I would try with 1
SB> spoolthreads, 1 remote delivery, 3 max-connections and assuming you only
SB> have pop3 and smtp you can use 1+1+3*2 = 8 max-threads (but you can even
SB> use a bigger number as they won't be allocated if they are not declared)

SB> Stefano

SB> PS: if JAMES does not start you should check the logs and report the
SB> errors, so we can help.


SB> ---------------------------------------------------------------------
SB> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
SB> For additional commands, e-mail: server-user-help@james.apache.org






---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re[2]: James too many threads

Posted by Dima Retov <di...@axisway.com>.
Stefano,

Thank You

Dima


Thursday, October 18, 2007, 1:07:11 PM, you wrote:

SB> Dima Retov ha scritto:
>> Thank you.
>> 
>> Actually I had 150 threads and now I have 54.
>> (I have decreased max-connections from 10 to 3)
>> 
>> I have min-threads 1 and spare threads 2.
>> (I think this must decrease allocated threads to 1 thread when they
>> are not used)
>> 
>> RemoteDelivery and remotemaneger were already set 1 thread.
>> 
>> I have smtp, smtps and pop3s services.
>> I am the only user who uses smtps and pop3s. So I guess it must
>> allocate 1 thread per smtps and pop3s if I do not read or sent emails
>> for some time.

SB> Unfortunately this is not how things works in JAMES. Threads pool are
SB> fully allocated to the max and never released. They instead will wait
SB> for some notification but they won't be deallocated.
SB> The min-thread and the spare configuration IIRC are ignored.

SB> If you want to know exactly what are the 54 threads you have in memory I
SB> suggest to ask a stacktrace (jstack <pid> or KILL -3 <pid> and look in
SB> the console). The name of each thread or the first lines of each stack
SB> should be useful to understand what each thread is and what is doing.

SB> If you want smtps, pop3s and remote manager to use less connections than
SB> smtp then you'll have to tweak the configuration a bit more:

SB> 1) Add a new connection manager block in the assembly.xml file:
SB> <!-- My tiny Connection Manager block -->
SB> <block name="altconnections"
SB> class="org.apache.james.util.connection.SimpleConnectionManager" >
SB> <provide name="thread-manager"
SB> role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
SB> </block>

SB> 2) Add a new <altconnections> configuration in your config.xml:
SB> <altconnections>
SB>   <idle-timeout>30000</idle-timeout>
SB>   <max-connections>1</max-connections>
SB> </altconnections>

SB> 3) Bind your smtps and pop3s services to the altconnection in your
SB> assembly.xml:
SB> <block name="smtps (or whatever you named it)"
SB> class="org.apache.james.smtpserver.SMTPServer">
SB> <provide name="altconnections"
SB> role="org.apache.james.services.JamesConnectionManager"/>
SB> </block>

SB> Stefano


SB> ---------------------------------------------------------------------
SB> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
SB> For additional commands, e-mail: server-user-help@james.apache.org




-- 
Best regards,
 Dima                            mailto:dima@axisway.com


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: James too many threads

Posted by Stefano Bagnara <ap...@bago.org>.
Dima Retov ha scritto:
> Thank you.
> 
> Actually I had 150 threads and now I have 54.
> (I have decreased max-connections from 10 to 3)
> 
> I have min-threads 1 and spare threads 2.
> (I think this must decrease allocated threads to 1 thread when they
> are not used)
> 
> RemoteDelivery and remotemaneger were already set 1 thread.
> 
> I have smtp, smtps and pop3s services.
> I am the only user who uses smtps and pop3s. So I guess it must
> allocate 1 thread per smtps and pop3s if I do not read or sent emails
> for some time.

Unfortunately this is not how things works in JAMES. Threads pool are
fully allocated to the max and never released. They instead will wait
for some notification but they won't be deallocated.
The min-thread and the spare configuration IIRC are ignored.

If you want to know exactly what are the 54 threads you have in memory I
suggest to ask a stacktrace (jstack <pid> or KILL -3 <pid> and look in
the console). The name of each thread or the first lines of each stack
should be useful to understand what each thread is and what is doing.

If you want smtps, pop3s and remote manager to use less connections than
smtp then you'll have to tweak the configuration a bit more:

1) Add a new connection manager block in the assembly.xml file:
<!-- My tiny Connection Manager block -->
<block name="altconnections"
class="org.apache.james.util.connection.SimpleConnectionManager" >
<provide name="thread-manager"
role="org.apache.avalon.cornerstone.services.threads.ThreadManager" />
</block>

2) Add a new <altconnections> configuration in your config.xml:
<altconnections>
  <idle-timeout>30000</idle-timeout>
  <max-connections>1</max-connections>
</altconnections>

3) Bind your smtps and pop3s services to the altconnection in your
assembly.xml:
<block name="smtps (or whatever you named it)"
class="org.apache.james.smtpserver.SMTPServer">
<provide name="altconnections"
role="org.apache.james.services.JamesConnectionManager"/>
</block>

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org