ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Get order for multi threaded app's

Post new topic  Reply to topic Goto page 1, 2  Next
 Get order for multi threaded app's « View previous topic :: View next topic » 
Author Message
x061294
PostPosted: Fri Feb 24, 2006 5:41 am    Post subject: Get order for multi threaded app's Reply with quote

Acolyte

Joined: 05 Apr 2005
Posts: 62

I'd like to know if someone know's the order MQGET's are satisfied with multi threaded applications, running as client and local app's.

The situation is that I have two multi threaded applications, one running on a Windows box that has a 5.3 queue manager on it, and one running as a client to that box. Both open up 5 threads, doing connections and MQGET with wait against a queue. So now there are 10 open handles to the messages on that queue. For the sake of argument, let's say the server app started up first, then the client app.

My belief is that MQ would "queue" up the get requests, so the first 5 get handles would be for the server, and the next 5 would be for the client app. Therefore, if a message would arrive on that queue, the first get request in the "queue" would be handed the message and go off and do it's processing. When it is done it would issue another MQGET, and would be added to the end of the queue of get's waiting to be fulfilled. Following this logic, if messages arrived in a drip fashion and all backend processing finished before the next message arrived, the processing would be handled 5 by the server app, 5 by the client app, 5 by the server app, ...

However, based on what we're seeing when running tests, that isn't what is happening. So I thought I'd ask and see if someone know's the way that these get requests are serviced.

What we're encountering is that the local application (when running full out, not slowly in this drip fashion as I used as the example) is getting 90% of the messages while the client app is getting only 10%. Or even 95/5. Now obviously network latency comes into play as to how many messages the local app can process in the same amount of time that the client app can, but since the backend processing of the messages can take several minutes before finishing and coming back for another message, the latency issue is not in play here.

So what we appear to be seeing is that if there are outstanding MQGET's against a queue, for client and local, the queue manager is giving preference to the local requests. Which goes against how I thought MQ would "queue" up the MQGET requests. Which makes our load balancing not work out to 50/50, which is the net result of what we're trying to do.

Hence my qeuestion, does anyone know how the queue manager makes it's determination as to which MQGET to hand the message off to?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Feb 24, 2006 6:04 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

What happens if you start the client app before you start the server app?

I don't think you have a lot of control over this in general. There's nothing documented that I know of on how this is handled , so it works however it works at the discretion of the MQ development team.

In general, the first handle that is available will get the message. The question is "which one is 'first'?" And I suspect that the answer to this doesn't in any way depend on whether or not there are ten threads from one application, five threads from two, or one thread from ten applications.
_________________
I am *not* the model of the modern major general.


Last edited by jefflowrey on Fri Feb 24, 2006 6:51 am; edited 1 time in total
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Fri Feb 24, 2006 6:06 am    Post subject: Re: Get order for multi threaded app's Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

x061294 wrote:

My belief is that MQ would "queue" up the get requests, so the first 5 get handles would be for the server, and the next 5 would be for the client app. Therefore, if a message would arrive on that queue, the first get request in the "queue" would be handed the message and go off and do it's processing. When it is done it would issue another MQGET, and would be added to the end of the queue of get's waiting to be fulfilled. Following this logic, if messages arrived in a drip fashion and all backend processing finished before the next message arrived, the processing would be handled 5 by the server app, 5 by the client app, 5 by the server app, ...

You should not make this assumption. There is no documentation that supports it.

In other words, MQ is working as designed.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
mvic
PostPosted: Fri Feb 24, 2006 6:27 am    Post subject: Re: Get order for multi threaded app's Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

x061294 wrote:
I'd like to know if someone know's the order MQGET's are satisfied with multi threaded applications, running as client and local app's.

API calls get serviced in the same order in which they arrive at the queue manager.
Back to top
View user's profile Send private message
markt
PostPosted: Fri Feb 24, 2006 6:43 am    Post subject: Reply with quote

Knight

Joined: 14 May 2002
Posts: 508

>> API calls get serviced in the same order in which they arrive at the queue manager.
You CANNOT make such an assumption, and it is clearly untrue in a number of cases. There are NO guarantees about which waiting MQGET retrieves the message (other than the specific vs non-specific MQGET(WAIT) behaviour).

The product documentation is explicit - rather than being quiet on the question it states that the behaviour is undefined. So you should never build anything that relies on, for example, an even distribution.
Back to top
View user's profile Send private message
wschutz
PostPosted: Fri Feb 24, 2006 6:55 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Can you tell us why you want this behavior? It seems odd to worry about evenly distributing workload between a server and client bound set of applications .... perhaps there is a solution that uses documented features of MQ. (clustering?)
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
PeterPotkay
PostPosted: Fri Feb 24, 2006 9:25 am    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

wschutz wrote:
.... perhaps there is a solution that uses documented features of MQ. (clustering?)

And even clustering won't insure equal distribution, as explained in this long thread:
http://www.mqseries.net/phpBB2/viewtopic.php?t=17607&postdays=0&postorder=asc&start=15

The only way to accomplish this is through custom code.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
x061294
PostPosted: Fri Feb 24, 2006 11:52 am    Post subject: Reply with quote

Acolyte

Joined: 05 Apr 2005
Posts: 62

What we had was a local based applicaton that was running into capacity issues, so, we thought we'd add another server to help process some of the load. However, when adding this server into the mix, it only took 5% of the load off the server, the rest stayed on the main server.

We certainly could introduce another server, make that the queue manager server, and client both the app's into it. And that might make the distribution more equal. But without knowing the reason for not servicing the MQGET's equally, we didn't know if that would solve the problem.

I'm not worried about exactly 50/50, and depending on network and other factors I certainly wouldn't have been surprised to see a 60/40, or worst case 70/30. But I certainly didn't expect 95/5.

As for

Quote:
You CANNOT make such an assumption, and it is clearly untrue in a number of cases. There are NO guarantees about which waiting MQGET retrieves the message (other than the specific vs non-specific MQGET(WAIT) behaviour).

The product documentation is explicit - rather than being quiet on the question it states that the behaviour is undefined. So you should never build anything that relies on, for example, an even distribution.


I guess you learn something new every day. I wasn't building directly on that thought, it just seemed reasonable.

So, is anyone distibuting, through a single queue manager/queue, load across multiple app servers in a pretty equal level?

Thanks.
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Fri Feb 24, 2006 11:57 am    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

x061294 wrote:
So, is anyone distibuting, through a single queue manager/queue, load across multiple app servers in a pretty equal level?

We have a few apps that have 3 MQ Client threads pulling from a local queue. Anytime we bothered to check to see what the distribution was, it fluctuated every day, but was never 33/33/33. The one thing that we could count on was that if there was a thread with an outstanding Get with wait, and a message arrived, it would get picked up instantly.

Since the queue depth is staying at zero, we are happy, even though on any one day any one of the three threads may have processed significantly more messages than its brothers.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Feb 24, 2006 12:00 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you increase the number of threads on the client app, you will increase the likelyhood that it will process more work. Similarly with decreasing the threads on the server app.

Your best bet may actually be to modify the MIRRORQ api exit to do loadbalancing for you between two queues, and point the server at one and the client at the other.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wschutz
PostPosted: Fri Feb 24, 2006 12:12 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Quote:
What we're encountering is that the local application (when running full out, not slowly in this drip fashion as I used as the example) is getting 90% of the messages while the client app is getting only 10%. Or even 95/5.
But isn't this saying that you can handle the workload alone with the server application? If message were coming in faster than the server applications threads could handle, you'd see the client application getting more of the messages. (Because then, when the message come into the queue, none of the server threads would likely have an outstanding mqget where-as the client application would.)
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
x061294
PostPosted: Fri Feb 24, 2006 12:19 pm    Post subject: Reply with quote

Acolyte

Joined: 05 Apr 2005
Posts: 62

There is concern by having one server running at 80 - 90% utilization while the other is at 5 - 10% utilization. Technically there is room on the first server to continue processing, and we could take the approach that wait until that server goes 100% before processing is failing over to the second server, but that just worries me, and others.

I can take a look at the api and see about that balancing. Again, logically it just made sense to me that a MQGET thread is an MQGET thread is an MQGET thread, regardless of client versus local. But it doesn't appear that that is the case. I'm sure that there are good reasons for that, but, then I would think that there should be a way to cause this result, and I don't know what that would be.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Feb 24, 2006 12:23 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you want to change the distribution of work in your situation, then change the number of threads on the server and change the number of threads on the client.

As has already been said, there isn't a way to control this in MQ - because that's the way it's been written.

You can raise a feature request to have this added to a future release of the product - but that won't help you in the short term.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wschutz
PostPosted: Fri Feb 24, 2006 12:24 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Well, you could put a 2nd qmgr on the "client" machine and then just use normal MQ clustering to distribute the messages round-robin to the queues (even, as Peter says, it might no be "perfect", but it sounds like you don't need perfect distribution).
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
x061294
PostPosted: Fri Feb 24, 2006 12:27 pm    Post subject: Reply with quote

Acolyte

Joined: 05 Apr 2005
Posts: 62

Thanks all
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ API Support » Get order for multi threaded app's
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.