Some of the efficient ways in which you could write your code, this would not just improve memory leaks, I/O overheads, threads blockage, etc. This would make a huge difference in the way your application performs. So enjoy reading and try implementing!!
- No Append to Doc List in a loop. Use Vector instead.
- Focus on the inner loop and not on the outer loop in case of nested loops
- Use reference of docs stops memory leaks, drop variables
- Transformer is better than service invoke as it has minimal overhead on pipeline
- Use Java svcs in case of CPU intensive like nested loops.
- Tune Java Svc by using StringBuffer instead of direct read/write as they call I/O directly or direct string concat ,etc..
Because String buffer creates one object however large the array while string concat and things like that create so many objects and hence inefficient garbage collection and hence memory leaks.
- Use Doc stream instead of reading direct xml files.
- Use IS XML parser for large file handling, see WmSamples in wiki for examples.
- Validate doc once and not in loop.
- Parallel processing for huge line items because they can be processed parallely and that required us to create small independent docs instead of large
- Guaranteed Vs Volatile persist only if required Guaranteed is memory consuming.
- Sending and processing smaller docs is heavier than processing one large example when you are storing them large is better.
- Use threads and make them asynchronous. For long running HTTP call we can use another thread instead of retry.
- Asynchronous is better
- Use data direct db driver over odbc drivers as they are fast and recommended.
- Remove disabled services because the flow still checks that step while running. Remove docs and services not being used.
- Remove those services which were never called while running a full test suite , you can find that in IS page under service usage services which are never called.
- Disabled packages are never loaded by IS so no issues.
- Stateless faster than state full as no state or session object needs to be saved. If calls in the same IS then its not stateful.
- Throwing an exception is resource intensive. Catching it clones the pipeline and fills error log. Choose no logging in Designer.
- If a join condition is there put it at the top because flow goes and check in top to bottom order.
- Clear pipeline iterates over all the steps to find what to drop from memory and hence avoid , rather drop variables wherever necessary or Choose only a portion of the pipeline by scope when calling a service.
- Avoid event handlers, turn off listeners which are not required ex. FTP , https, email listeners ,etc..
- Static data used a lot of times can be put in cache or in terracotta array.
- POST is 25 % faster than GET in REST
- MTOM is better than XML while passing soap attachments
- Stored procedure / views are better than SQL statements if the DB call is duplicate all the time. Also limit the no of connections in DB pool if they are not used.
- Reduce document history to save memory as it is used for duplicate checks and once and only once delivery
- Flat file adapters better than writing.
- SSL causes performance hit. If the call you are making to an application inside the same network or Organisation then why use SSL because you are already protected by your enterprise security layer?
- Use basic auth instead of SAML authentication as it fetches tokens and in case of a load balancer the no of hops are so much that there is no value ad
- Minimal logging is very important as it is I/O overhead.
- Audit logging is better if it is synchronous unlike web services.
watt.server.auditlog=off in server.cnf for no logging.
- Make fewer steps in your BPM process model eligible for resubmission as it saves the entire pipeline. Minimize logging of pipeline variables. DO IT ONLY WHERE IT IS REQUIRED.
- Aggregate steps as much as possible rather than having so may steps in your BPM, like write most of the logic in one service and use that service as one step in the BPM.
- Do not use pub.remote.gd guaranteed delivery service instead of use pub.remote.invoke.
- Divide large services into smaller manageable pieces of code.
- Instead of doing dynamic host look-ups rather add those IP addresses and hostname in the /etc/hosts file.
- Minimum connections in your Database connection pool should be 1 and not 0. It was suggested to keep that 0 because Db connection pools earlier had a bug and making that 0 would flush all the stale connections which were sitting in the pool but were never available for use but as this is addressed now 0 is not even required.
- Use spy property in the JDBC connection pool on the IS page to investigate your connection pool. It will tell you the health of your conn pool and that can be seen in IS server.log
- You can use the Oracle AWR report analysis for checking the performance of your database. For e.g concurrent reads, locks can be analyzed using this.
- Avoid SELECT * when so many columns. Using joins is better than having multiple selects in one SQL query.
- Use EXISTS instead of COUNT(*). Instead of individual SQL statements inside a loop write one that does it all.
- Per core(CPU) we can have 150-200 threads but it depends on a lot of factors as well depending on the application. Sometimes decreasing the thread count improves the performance and hence understanding the application is of prime importance as to what are bottlenecks, what are the I/O requests, etc…
- Glue in MWS is for web services and Jetty is for connectors
- There are two levels of threads we must understand one is CPU level and the other is the application JVM level.
- vmstat is a tool used to collect and report data about your system memory
- Garbage collection normally kicks in when memory utilization is over or around 72%.When Garbage collection average time is under 1 sec you can believe that your system is efficient and performing well.
- Performance test scenario must be as close to real live test data, configurations, software versions along with hardware and resources available. Always test with more data than you would ever have in a real scenario and this must also cover high volume periods(eg. thanksgiving day)
- Create thread dumps using below steps and then use http://fastthread.io/. For Garbage collection you can use http://gceasy.io/
- Kill -3
- Windows(Ctrl + Break)
- Nanoscope (brilliant tool to identify the performance of webmethods services)
Note: to analyze your thread utilization and also understand how your garbage collection works run the below files under the location: C:\SoftwareAG\jvm\jvm\bin. Or else you could also use Universal GC Log Analyzer
For more best practices, please take a look at the guides: