[SOLVED] ActiveMQ Issues - Out of Memory - Server crashing

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: ActiveMQ Issues - Out of Memory - Server crashing

Post by Jaymer »

this thread brought to light several issues.
NOTE _ I'm not blaming Aware/Vlad for anything. I'm not criticizing the product. Not in any way. I'm describing what I see going on because it will help me (and others hopefully) design Aware BOs to work more efficiently once I know whats going on behind the scenes. The Aware "concept" and the fact you don't need to be a professional programmer to write these apps is still true. You don't really need to know whats going on behind the scenes, which is why some ideas in the next post "Food for Thought" might help you avoid unexpected results.


1) I had previously posted about higher CPU time when a process ran - AND - you had a server Output window open. Under v8+, it was possible to open a grid and then observe the TomCat Output still scrolling for many seconds after the grid had completed on the client PC. Esp. when you have conditional formatting/buttons on each row in that returned grid... each grid row result may "expand" into 3,5 or more actual lines in the Tomcat window. And if the user does a next page, or a sort, then there's even more rows that still have to be displayed in the Tomcat window.

I believe this is one reason why CHRIS29 had discovered those Output windows need to be closed. A Habit I've tried to get in myself, but still can bite me as it did yesterday when I had them open and got a User issue with a grid "hanging" because it had already reported a Out of Memory issue.
The Tomcat window is the biggest Offender I think and you may be able to leave open the Server Output.

2) This process also got me looking more indepth at MS SQL SERVER Profiler Traces... to see why [it appeared] one grid was responsible for causing this OOM issue.
WHAT I DISCOVERED (that others may already know) is when you have a BO with 50 fields, for example, and you make a grid call to show 25 records:
a) a SELECT * from BO is issued, returning ALL fields, regardless of what you are displaying in the Grid
b) a SELECT * FROM PS_BO is issued for each reference in that row, regardless of whether you display linked fields in the Grid

EXAMPLE: Lead system. Each Lead has a ps_EnteredBy, ps_AssignedTo, ps_ClosedBy, ps_Branch, ps_Tenant
Just displaying the first 25 Leads causes:
SELECT TOP 25 Lead.*
SELECT * FROM REGULARUSER for EnteredBy
SELECT * FROM REGULARUSER for AssignedTo
SELECT * FROM BRANCH for 1 branch
SELECT * FROM TENANT for 1 Tenant

Clicking NEXT PAGE reissues similar statements, except the TOP xxx grows. For the 3rd page of 25 rows shown, the statement is:
SELECT TOP 75 Lead.*
Internally, Vlad knows he only is interested in the 51-75 rows, but the underlying database still returns more and more rows as the user pages through a grid.

THE FULL MONTY and the SOLUTION
3) taking all this into account, I started reviewing what were unused fields and references in my App.
This particular app was started using the CRM as a framework.
the BO Group COMMUNICATION contains 4 BOs (email out, email in, sms, ???). We were only using Email in this list. But Queries, procedures, etc. had been built on "Communication", so you can't easily remove tables from the group and still Publish because you get a rash of Integrity issues. This is why this hadn't been done in the past. So I bite the bullet and dig in to start cleaning up this BO.
This wasn't a big deal, but it came to light when examining the SQL Trace and seeing a over complicated query (for what I needed) for showing Emails - since the Query was built on Communication (not just OutgoingEmail) it had a join of all tables in the group.

OK, here's the solution, promise
4) I started looking at DOCDATA fields in the App. Esp. in the lead table. There WAS one - from the CRM - we were not using it, but I deleted it anyway.
THEN, I realized a PHOTO was in RegularUser.
We were not using it either but it WAS in the UserEdit form and some users had had uploaded photos.

I ran a SQL Query using DATALENGTH([Photo_DOCDATA]) and found most photos were around 100k, but THE PHOTO of the user where we saw ALL THE SLOWNESS AND OutOfMemory issues was...
:oops: 12 Megabytes :oops:

Yes, take a picture of yourself at a portrait studio, have them give you a CD cause the image is so big, and use THAT DAMN HUGE IMAGE as your tiny little picture in the CRM - Makes sense to me !!!! :roll:

And, reference back to # 2 above, she was the sales rep assigned to all those leads.
So for every read of every grid line, her "Select * from LoggedInRegularUser" dataset included a 12Meg image that wasn't even needed.

A quick
Update [R3].[dbo].[REGULARUSER]
set Photo_DOCDATA=NULL, Photo_DOCTYPE=Null
wiped all that crap out and performance IMMEDIATELY returned to normal.
Last edited by Jaymer on Fri Jun 22, 2018 2:31 pm, edited 1 time in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by Jaymer »

Food for thought:

If you have a photo in a Tenant master, to allow for a nice attached Logo, then it "appears" thats going to be transmitted in just about every grid for BOs that point directly to the Tenant.
making sure you use Stored in FS (instead of in db) would seem to solve this.

Make sure you resize or limit the upload size of an image

Not only photos, but just Documents stored in the db inside a Owner or Parent record may affect performance of child related activities that point UP to that parent rec.


ALSO
I'm NOT saying that the way Vlad is doing things is wrong.
Lets say you make a grid with only 6 fields. How is Vlad to know that you don't need the 7th field in a formula to show/hide a button in Row Operations (or in the Applicable when box)? He can't know that, so he returns all the fields.

One thing frequently said is to NOT to put lots of temp fields in LIRU - I don't recall the stated reason for that. Maybe in some designs, people have run across a similar binary data issue in LIRU that has hindered performance and gave birth to this idea. Seeing the Trace files, and that RegularUser is hit so many times (as described in the above "Solution" post), one more read of LIRU to get some saved parms hardly seems like it would be any issue at all.
However, as an example, in a certain design, where every user must have a signed Waiver and the designer said "Lets just stick this in the User File" and now there's a huge Scanned Image stuck in Regular User, then YES, certainly, there would be a massive performance hit reading LIRU many times.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: ActiveMQ Issues - Out of Memory - Server crashing

Post by BobK »

chris29 wrote:We have a similar issue. Found that you need to ensure that all log outputs are closed and put the following in the cp.ini at the end

-vmargs
-Xmx1024M
Chris, are you sure that works?

I needed to pass an argument to the JVM and did some googling and found that the above is how you pass arguments to the eclipse JVM.
AwareIM is built on the eclipse framework but it is NOT eclipse.
When I put my argument in cp.ini like you did above, I did not get the result I was hoping for.
To get a better idea of what was being passed to JVM, I wrote a small java plug-in to display the arguments being used by the JVM and my argument was not displayed.
I also tried adding my argument to startAwareIM.bat. After restarting AwareIM with that old batch file, my argument was displayed.
After some experimentation, I found that adding my argument to startupOptions.props and starting AwareIM with cp.exe, my plug-in displayed my argument and I was able to get the results I needed with the argument set.
Bob
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by tford »

making sure you use Stored in FS (instead of in db) would seem to solve this.
Great detailed post, Jaymer. Very thankful for your time investment to share what you learned in such a detailed way.

I'm not sure I understand the mechanics of "Stored in the FS (instead of in db)" and the impact of efficiency.
Tom - V8.8 build 3137 - MySql / PostGres
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by Jaymer »

thanks Tom,
i'm not sure you were actually asking a question about "stored in DB vs. FS", but let me add this:

Consider MySQL vs. SQL Server.

MySQL stores physical files on the filessystem for each BO.
MSSql & oracle do not - all their data is co-mingled in database pages inside 1 big physical file for the entire db (there are exceptions).

So, I always questioned the validity of moving Documents (lets use this for large blob binary objects of any kind) out of the DB and into the FS FOR MY SQL because they were really already in the FS. Whats the diff between 1000 seperate images in C:\wherever vs. 1000 images stored as binary inside c:\ProgramData\MYSQL\Data\Documents.MYD?

With MSSql its different (IMHO) because all those images are bloating the single database file. Someone else would have to weigh in on pros vs cons of this structure.

OK, but back to the issue at hand.
Maybe some of the speed issues (and systems dragging performance-wise) seen over the past few years through many posts on the Forum were not just because of the images in the db, but the issues I posted in the "Solution".
From what I see, Images stored in a child table to the RegUser wouldn't impact performance... because many queries from other transactional files that point to a User record are NOT going to ever see these large fields stored in subordinate related rows.
But one could easily see a system that allowed a high res image of an employee or customer or contact - and might believe "Sure, its in the User record, but I'm not displaying except on ONE screen, so its presence is irrelevant to my overall system." au contraire
Remember, this issue isn't related to just Pictures - Documents also.
It might be possible that if my BSV stored that image in the FS, then this would never have become an issue.
Let Aware do a "Select * from BO" all day long, but since the image isn't being transmitted (only a string thats the PATH to the Doc), then it avoids all this Query overhead.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BLOMASKY
Posts: 1471
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

What does the data addes to the CP.INI do?

Post by BLOMASKY »

I thought that was just used for the configurator.

1st question: What is the VARS folder used for?
2nd question: why does adding:
-vmargs
-Xmx1024M
to the end of the CP.ini do?

Thanks
Bruce
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by Jaymer »

Bruce,
Along the lines of the server and tomcat Output windows being open,
and the message queue backing up because of a large number of messages,
thus causing an out of memory issue,
I think the plan is to add more memory so the control panel can buffer more of those backed up messages since it is consuming them a lot slower than they are coming in.

That I think is Chris’s plan, but I’m not sure why they had to be in the .ini since it seems like you could do the same thing in StartAwareIM.bat (as BobK was pointing out)..

Never have figured out what Vars stuff was for.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
chris29
Posts: 173
Joined: Sat Feb 06, 2010 1:45 am
Location: Australia

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by chris29 »

Adding vmargs to cp.ini was a recommendation from Vladimir and it works for our servers. The memory settings for aware/tomcat we have in startupOptions.props

Have a look at VisualVM, it will let you know what is happening with memory.

https://visualvm.github.io/download.html
Version 8.5 - Windows using MySql 8 and SQL Server - 64bit
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by Jaymer »

CORRECTION

With respect to the above post concerning parms sent to vmargs (by Chris29), that post(s) is in error.
Please see this thread: https://www.awareim.com/forum/viewtopic.php?f=1&t=10428
Last edited by Jaymer on Wed Jul 11, 2018 2:43 pm, edited 2 times in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by weblike »

Hi,

I have removed all the LIRU images from DB (using the FileSystem method now).
What I keep doing on every update of Aware:
1. Rename the AwareIM folder with my Custom Folder
2. Follow rennur resources by updating JDK, Tomcat to 9.0.10, ActiveMQ --: from here https://github.com/RennurApps/AwareIM-resources

These modifications I used to do even in 7.0 and it worked fine, until now with 8.1 (the app still crashing and the users keep calling).

Am I doing something wrong or those modifications are not suitable for 8.2 anymore.
I even upgraded my VPS to 32GB of RAM / and 8 vCPU.

Anyone is exepriencinf this or itțs only with my installation?

Thank you.
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by Jaymer »

George, I don't think many will see your post, since this is marked [SOLVED].
please post as a new thread.
jaymer...
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
ACDC
Posts: 1142
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by ACDC »

2. Follow rennur resources by updating JDK, Tomcat to 9.0.10, ActiveMQ --: from here https://github.com/RennurApps/AwareIM-resources
Have you tried a standard installation without doing the above
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: [SOLVED] ActiveMQ Issues - Out of Memory - Server crashi

Post by weblike »

ACDC wrote:
2. Follow rennur resources by updating JDK, Tomcat to 9.0.10, ActiveMQ --: from here https://github.com/RennurApps/AwareIM-resources
Have you tried a standard installation without doing the above
Exactly that I did it yesterday, but users still report freeze of the applications.
So I have: Same VPS from 7.1 (worked ok); same apps from 7.1 (reports adjustments to update to 8.1).
No clue of the problem.
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
Post Reply