Title: BP2190: Best Practices: SonicMQ Configuration and Tuning
1BP2190Best Practices SonicMQ Configuration and
Tuning
- Bill Woodwood_at_sonicsoftware.com
- Technical Fellow
2Agenda
- General Comments
- Background and Tradeoffs
- Key Configuration Parameters
- Where to Create Configurations
- Putting it all Together
- Summary and Questions
3Sample Pub/Sub Durables
SonicMQ Broker
Subscriber
Dur. Sub Connected
?
receive
OutgoingMsgBufferSize
ack
1K
75K
Publisher
150 K
?
publish()
PsGuarMsgBufferSize
DbConnect
Dur. Sub Disconnected
PsDbQueueSize
db
500 K
RecoveryLogPath
4General Comments
- Tuning and Configuring SonicMQ
- Parameters are available in Version 5.0
- Access via
- Sonic Management Console (SMC)
- Management API
- Best practices
- SonicMQ v.4 has same parameters
- Some name changes
- Set in broker.ini
5Agenda
- General Comments
- Background and Tradeoffs
- Key Configuration Parameters
- Where to Create Configurations
- Putting it all Together
- Summary and Questions
6What we do!
SonicMQ Broker
Producer
Consumer
7What we really do!
SonicMQ Broker
- As necessary,
- Check permissions
- Log
- Deliver to clients
- Buffer for slow clients
- Save for disconnected
Producer
Consumer
send()
process acknowledge
TCP/IP
Disk
8and we do it many times!
Many Receiving Connections
Many Sending Applications
SonicMQ Broker
Producer
As necessary,
Consumer
send()
Check permissions
Producer
Log
process
Deliver to clients
send()
Buffer for slow clients
process
send()
Buffer for disconnected
Many Senders per Application
Many Receivers per Application
Disk
9The Problem
- Many pieces of many applications sending many
messages - Limited Resources
- Disk
- Network
- Consumers
- Goal
- Maximize throughput by minimizing contention for
resources!
10Our Solution
Optimize use of system resource
Get Messages ready for transfer as fast as
possible
Multiple Message Processing Threads
Message Buffer
Output Buffer
LimitedResource
Hold Messages so Threads dont Wait
Marshall bytes appropriate to System Resource
11Messages, Buffers and Bytes
- Common Design Pattern in SonicMQ
- Dont block on Limited Resources
- Allow Message processing to continue
- Message Buffer
- Holds messages to free up processing threads
- Output Buffer
- Optimize use of System Resources
- Tuned for transferring data (not messages)
12Message Buffers
- As they fill, change behavior
- Throttle producers
- Block processing threads
- Free space
- Message Buffer Size
- Not an absolute Size
- Only a Threshold for changing behavior
- Sizing Guidelines
- Size for bursts
- When producers are TEMPORARILY too fast
13Agenda
- General Comments
- Background and Tradeoffs
- Key Configuration Parameters
- Where to Create Configurations
- Putting it all Together
- Summary and Questions
14Key Configuration Parameters
- Recovery Log
- Topic Subscribers
- Non-Durable
- Connected Durable
- Disconnected Durable
- Reconnecting Durable
- Queues
- Short and Long-term Storage
- Transactions
15Recovery Log
RecoveryLogMaxFileSize
Messages and acks from multiple producers and
consumers
RecoveryLogPath
RecoveryLogQueueSize
500,000 bytes
8,196 bytes
Recovery Logs
RecoveryLogBlockSize
BROKER_RECOVERY_LOG_PARAMETERS.RECOVERY_LOG_FLUSH
_DELAY
16Subscribers
OutgoingMsgBufferSize
Messages from multiple publishers
TCP/IP (network)
150,000 bytes
1,024 bytes
BROKER_CONNECTION_BUFFERS.AGENT_SENDER_OUTPUT_BUF
FER_SIZE
TcpNodelay
17Durable Subscribers Connected
BROKER_CONNECTION_BUFFERS.AGENT_SENDER_OUTPUT_BUF
FER_SIZE
OutgoingMsgBufferSize
TCP/IP (network)
Messages from multiple publishers
150,000 bytes
1,024 bytes
Guaranteed List(Message Buffer)
PsGuarMsgBufferSize
18Durable Subscribers Disconnected
Database Parameters DbConnectJdbcDriver etc.
PsDbQueueSize
Messages from many publishers, targeted for many
disconnected durable subscribers
500,000 bytes
DB classes
Database
(i.e. Long-term Storage Pub/Sub)
19Durable Subscribers Reconnecting
WaitMsgBufferSize
OutgoingMsgBufferSize
BROKER_CONNECTION_BUFFERS.AGENT_SENDER_OUTPUT_BUF
FER_SIZE
75,000 bytes
TCP/IP (network)
Messages from multiple publishers
JMSClient
Message Buffer
Output Buffer
Guaranteed List
Reconnect Logic
PsGuarMsgBufferSize
BROKER_PUBSUB_PARAMETERS. THROTTLE_PUBS_DURING_RES
TORE
BROKER_PUBSUB_PARAMETERS.RESTORE_MSGS_FC_COUNT
20Queues
QueueSaveThreshold
QueueMaxSize
QueueDeliveryThreads
TCP/IP (network)
Messages from multiple senders
1,024 bytes
Queue (on disk)
Queue (in memory)
Message Buffer
BROKER_CONNECTION_BUFFERS.AGENT_SENDER_OUTPUT_BUF
FER_SIZE
21Long-term Storage Point-to-Point
Database Parameters DbConnectJdbcDriver
PtpDbQueueSize
Messages from many senders for Queues exceeding
their QueueSaveThreshold
500,000 bytes
DB classes
Database
22Transactions
TxnPrimaryThreads
TxnBufferSize
Messages from one transacted session
Delivery(Normal) Processing
Txncommit/ rollback
Message Buffer(32K)
BROKER_TXN_PARAMETERS.TXN_FLUSH_THREADS
file-based transaction
23Message Buffers and Priorities
OutgoingMsgBufferSize150K
Messages from multiple publishers using
different JMS priorities
TCP/IP (network)
Message Buffer
Output Buffer
low priority publishers flow-controlled first
Normal JMS Priority occurs in the middle
Publishers sending high priority message flow
controlled here
24Tuning and Message Size
- Big Messages
- dominated by disk and network speed
- Only tune parameters that matter
- Quality of Service
- Messaging Domain
- Large Buffers may increase latency
- Small Buffers
- will not cause failures
- may reduce concurrent processing
25Agenda
- General Comments
- Background and Tradeoffs
- Key Configuration Parameters
- Where to Create Configurations
- Putting it all Together
- Summary and Questions
26Sonic Management Console
- Mange Tab
- Broker Component
- Restart Broker
- For broker properties
- Re-initialize storage
- For Recovery Log and Database properties
- Use Templates for large deployments
27Setting Tuning Parameters
- Sonic Management Console
- Broker Properties
- Advanced Properties
- Queues Properties
- Sonic Management API
28Sonic Management Console
29Storage Parameters
30Subscriber Parameters
OutgoingMsgBufferSize
PsGuarMsgBufferSize
WaitMsgBufferSize
31Queue Properties
Broker-wide Queues Properties
Properties on Individual Queues
32Transaction Parameters
TxnPrimaryThreads
TxnSecondaryThreads
TxnBufferSize
33Sonic Management API
- APIs to support configurations through
- Programming
- Scripting
- package com.sonicsw.mq.mgmtapi
- IBrokerBean
- IQueuesBean
34Sonic Management API Example
import com.sonicsw.mq.mgmtapi.config. MQMgmtBea
nFactory domain IBrokerBean bb IBrokerBean.ITuni
ngParametersType params // Get the broker
config domain new MQMgmtBeanFactory() domain.co
nnect("Domain1","tcp//localhost2506","User","pwd
") // Load the Broker Bean for broker with the
view name // "/Brokers/Broker1" bb
domain.getBrokerBean("/Brokers/Broker1") params
bb.getConnectionTuningParameters() // Make
sure Nagle algorithm is disabled
(TcpNodelaytrue)if (!params.getTcpNodelay())
params.setTcpNodelay(true) // When done, save
changes domain.saveBrokerBean(bb)
35Sonic Management API Example
import com.sonicsw.mq.mgmtapi.config. MQMgmtBea
nFactory domain IBrokerBean bb IBrokerBean.ITuni
ngParametersType params // Get the broker
config domain new MQMgmtBeanFactory() domain.co
nnect("Domain1","tcp//localhost2506","User","pwd
") // Load the Broker Bean for broker with the
view name // Then get the Recovery Log
parameters bb domain.getBrokerBean("/Brokers/Bro
ker1")params bb.getBrokerRecoveryLogParameters
() // Set the RECOVERY_LOG_FLUSH_DELAY to
0 params.setIntegerAttribute(RECOVERY_LOG_FLUSH_D
ELAY, 0) // When done, save
changes domain.saveBrokerBean(bb)
36Agenda
- General Comments
- Background and Tradeoffs
- Key Configuration Parameters
- Where to Create Configurations
- Putting it all Together
- Summary and Questions
37What we do -- Revisited
- Which parameters apply in different scenarios
SonicMQ Broker
Producer
Consumer
38Pub/Sub Non-Durable
SonicMQ Broker
Publisher
Subscriber
Subscribers
?
OutgoingMsgBufferSize
publish()
1,000 K
receive
1K
150 K
All subscribers have a buffer. Non-Durables can
always use this!
Each publish() must wait for broker to check
security (and PERSIST, if necessary)
39Pub/Sub Non-Durable, No Security
(or NON_PERSISTENT_ASYNC)
SonicMQ Broker
Publisher
Subscriber
Subscribers
OutgoingMsgBufferSize
250K
1,000 K
publish()
receive
1K
150 K
If no security and NON_PERSISTENT, or
NON_PERSISENT_ASYNC, many publishes can occur
before anything has reached broker.
40Pub/Sub Connected Durable
SonicMQ Broker
Dur. Subs Connected
OutgoingMsgBufferSize
Publisher
1K
75K
Subscriber
?
publish()
150 K
?
receive
ack
PsGuarMsgBufferSize
Disk speed is KEY!
Used if ASYNC delivery
RecoveryLogPath
41Pub/Sub Durables
SonicMQ Broker
Subscriber
Dur. Sub Connected
?
receive
OutgoingMsgBufferSize
ack
1K
75K
Publisher
150 K
DbConnect
?
publish()
PsGuarMsgBufferSize
Dur. Sub Disconnected
PsDbQueueSize
Disk speed is KEY!
db
500 K
there is also the Reconnect Case
RecoveryLogPath
42Queues NON_PERSISTENT
(and below QueueSaveThreshold)
SonicMQ Broker
Queues
Sender
QueueMaxSize lt QueueSaveThreshold
n/a
send()
1,000K
1K
n/a
QueueDeliveryThreads
Not used hereQueue Receivers pull messages
Cant use this send always checks for existence
of Queue!
43Queues PERSISTENT sends()
(and below QueueSaveThreshold)
SonicMQ Broker
Queues
Sender
QueueMaxSize lt QueueSaveThreshold
n/a
send()
1,000K
1K
n/a
QueueDeliveryThreads
Disk speed is KEY!
RecoveryLogPath
44Queues
SonicMQ Broker
Queues
QueueMaxSize
QueueSaveThreshold
1K
n/a
Sender
DbConnect
QueueDeliveryThreads
n/a
send()
Long-term Store PTP
PtpDbQueueSize
Disk speed is KEY!
db
500 K
RecoveryLogPath
45Key Parameters
P/Snon-durable
P/S durable
PTP
Transacted
DRA
Message Size
Parameter
lt1K
20K
250K
OutgoingMsgBufferSize
1st
2nd
50K
150K
500K
PsGuarMsgBufferSize
1st
2nd
75K
150K
500K
WaitMsgBufferSize
1st
100K
250K
50K
PsDbQueueSize
2nd
1M
5M
Dflt
PtpDbQueueSize
2nd
1M
5M
Dflt
QueueDeliveryThreads
1st
10
10
5
Save Threshold
1st
5M
5M
1M
Maximum Size
1st
1M
10M
100M
RecoveryLogMaxFileSize
1st
1st
2nd
1st
Dflt
100M
1G
Dflt
RecoveryLogQueueSize
1st
Dflt
1M
DMQ Max. Size
2nd
1st
1M
10M
100M
Routing Queue Max.Size
1st
Dflt
1M
10M
TxnBufferSize
1st
32K
SizeN
SizeN
46Agenda
- General Comments
- Background and Tradeoffs
- Key Configuration Parameters
- Where to Create Configurations
- Putting it all Together
- Summary and Questions
47Final Points
- Dont tune without some test
- See Benchmarking white-paper
- Know what you are testing
- Latency
- Throughput
- Client or Broker
- Application Design
- Your biggest point of leverage
- Configuration only FINE-TUNES performance
48Further Reading
- SonicSoftware Developers Exchange
- http//www.sonicsoftware.com/cgi-bin/sonic.cgi/dx_
prime.w - Select Code Shares
- Click SonicMQ/Performance and Benchmarks
- Download
- SonicMQ V5 Tuning Guide
- Benchmarking JMS Based E-Business Messaging
Providers
49Obligatory Quote
50!
Allquestionsanswered
51www.sonicsoftware.com