Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Performance of javamail

Status
Not open for further replies.

sem

Programmer
Jun 3, 2000
4,709
UA
I wrote a simple program that sends emails. The issue is that it takes about a second to process Transport.send(message). My network is OK and I may send at least 5 messages per second using mail command. Is this expected behaviour? Can I set any settings to speed it up?
 
The mail programme is written in C, and is vastly different to the javax.mail API - so I would expect it to be quicker.

You asked if taking 1 second for the javax.mail API was, and I quote, expected behaviour. Well, I'm answering that question - yes, I think that is normal.

--------------------------------------------------
Free Database Connection Pooling Software
 
Is there any way to improve performance? Create multiple threads or launch multiple vm's or anything else? I mean that send is static method.
I hoped that I've missed some delay parameter :)

Regards, Dima
 
You could try caching the Session instance that you use if not already.

I would wrap the "send mail" call in a Thread though - that way I think you'll get nearer the performance you require.

Obviously, starting the JVM with a higher heap level using the -Xms -Xmx switches will help too.

--------------------------------------------------
Free Database Connection Pooling Software
 
SMTP is quite simple protocol so I wonder how a higher heap may help in sending 100 bytes via TCP/IP? I think that professional typist may achive the same speed with telnet :)
As for the thread advice - thank you, I'll give it a try as my Session instance is already the same and the whole second (and even more!) is utilized by Transport.send() only.

Regards, Dima
 
Increasing the heap size may not help - but remember that its not just 100 bytes of memory you are using, but all the object instantiation etc. The JVM by default only starts up with 16Mb, so if you are doing multithreading, its always a good idea to increase the heap size - you never know !

Another daft idea could be using Runtime.exec() to run the native "mail" command - it may be quicker !!!

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top