23.07.2013 Views

O'Reilly - Java Message Service

O'Reilly - Java Message Service

O'Reilly - Java Message Service

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />

provider for a given class of machine and eliminate the possibility of having exceeded the<br />

limits of your hardware.<br />

If the CPU or memory utilization does not approach its maximum, and the message<br />

throughput does not continue to improve as you add clients, then the bottleneck is probably<br />

disk I/O or network throughput. Disk I/O is most likely to be the bottleneck if you are<br />

using persistent messaging.<br />

7.1.2.4 Finding or building a test bed<br />

Building a test bed suitable for simulating a proper deployment environment itself can be a<br />

moderately sized effort. Most JMS vendors provide a performance test environment freely<br />

downloadable from their web site. In most cases, they provide a test bed sufficient for<br />

testing with one client. [1]<br />

[1] As of publication, SonicMQ is the only vendor providing a multiclient test bed.<br />

7.1.2.5 Long duration reliability<br />

Testing your application over a long period of time is very important. After all, it is<br />

expected to perform continuously once deployed. Verifying that the middleware behaves<br />

reliably is the first step toward ensuring long-term application reliability.<br />

Once you have a multi-client test bed in place, try running it for an extended period of time<br />

to ensure that the performance throughput is consistent. Start out by running the test bed<br />

while you can be there to monitor the behavior. Any long-term trends are likely to be<br />

detected in the first few hours. Things to watch for are drops in performance throughput,<br />

increase in memory usage, CPU usage, and disk usage. When you feel comfortable with<br />

the results you see, you may progressively start running tests overnight, over the weekend,<br />

or over a week.<br />

7.1.2.6 Memory leaks<br />

The term "memory leak" refers to a condition that can happen when new memory gets<br />

allocated and never freed over a period of time, usually through a repeated operation, such<br />

as repeatedly pumping messages through a messaging system. Eventually, the system runs<br />

out of available memory; as a result, it will perform badly and may eventually crash.<br />

Although <strong>Java</strong> has built-in memory management through garbage collection, it is an<br />

oversimplification to think that garbage collection permanently solves the problem of<br />

memory links. Garbage collection works effectively only when the developer follows<br />

explicit rules for the scoping of <strong>Java</strong> objects. A <strong>Java</strong> object can be garbage collected only<br />

if it has gone out of scope and there are no other objects currently referencing it. Even the<br />

best code can contain memory leaks, if the developer has mistakenly overlooked an object<br />

reference in a collection class that never goes out of scope.<br />

Therefore, you need to monitor for memory leaks during testing. Memory that leaks in<br />

small increments may be not be noticable at first, but eventually these leaks could<br />

seriously impact performance. To detect them quickly, it helps to use a memory leak<br />

detection tool like OptimizeIt! or Jprobe. Even if the JMS provider and other third-party<br />

<strong>Java</strong> products you are using contain obfuscated classes, tools like these still help you prove<br />

111

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!