MACH11 technology in IDS v11 brings unique opportunities to deploy applications in a scalable and continuously available system. Applications need to be aware of the isolation levels available, transaction management, and deal with the failover situations effectively. This talk will focus on understanding the MACH11 environment, hooks for application to exploit. This talk will also cover APIs enhancements to exploit MACH11 technology.
FAQ on developing and deploying applications on MACH11 (Informix Dynamic Server v11)
1. - 1 -
FAQ and Answers for developing,
deploying and maintaining applications
in MACH11 environment.
Keshava Murthy,
Architect, IBM, rkeshav@us.ibm.com
2. - 2 -
International Informix Users Group.2009 IIUG Informix Conference 2
Example of MACH11 Configuration
Primary
SDS
Blade Server A
<New Orleans>
Building-A
Blade Server B
<Memphis>
Disk
Disk
RSS
Blade Server C
<Denver>
Shared
Disk
Shared
Disk
Mirror
Blade Server D
<New Orleans>
Building-B
RSSTraffic
HDRTraffic
SDS
SDS
3. - 3 -
International Informix Users Group.2009 IIUG Informix Conference 3
Example of MACH11 Configuration
Primary
SDS
Blade Server A
<New Orleans>
Building-A
Blade Server B
<Memphis>
Disk
Disk
RSS
Blade Server C
<Denver>
Shared
Disk
Shared
Disk
Mirror
Blade Server D
<New Orleans>
Building-B
RSSTraffic
Connection Manager
HDRTraffic
SDS
SDS
SLA
4. - 4 -
International Informix Users Group.2009 IIUG Informix Conference 4
Example of MACH11 Configuration
Primary
SDS
Blade Server A
<New Orleans>
Building-A
Blade Server B
<Memphis>
HDRSecondary
Disk
Disk
RSS
Blade Server C
<Denver>
Shared
Disk
Shared
Disk
Mirror
Blade Server D
<New Orleans>
Building-B
RSSTraffic
Connection Manager
DBA
IDSAdmin
IDSAdmin
OLTP Apps
Reporting Apps
HDRTraffic
SDS
SDS
SLA
5. - 5 -
International Informix Users Group.2009 IIUG Informix Conference 5
P
S
H
R
Primary Server
SDS: Shared Disk Secondary Server
HDR secondary Server
RSS: Remote Secondary Server
U User/Application
C Connection Manager
Notations
6. - 6 -
International Informix Users Group.2009 IIUG Informix Conference 6
Example of MACH11 Configuration
Blade Server A
<New Orleans>
Building-A
Blade Server B
<Memphis>
HDRSecondary
Disk
Disk
RSS
Blade Server C
<Denver>
Shared
Disk
Shared
Disk
Mirror
Blade Server D
<New Orleans>
Building-B
RSSTraffic
Connection Manager
DBA
IDSAdmin
IDSAdmin
OLTP Apps
Reporting Apps
HDRTraffic
SLA
P
S
S
S
S
S
H
R
R
R
7. - 7 -
International Informix Users Group.2009 IIUG Informix Conference 7
What APIs can use MACH11?
P
H
RR
S
S S
CC
C based
Clients
Java
based
Clients
JDBC
sqli
drda
drda
sqli
odbc-PHP-Ruby
ESQL/C-4GL eGL
.NET
JDBC/PureQuery
Hibernate/Data
Services
8. - 8 -
International Informix Users Group.2009 IIUG Informix Conference 8
What APIs can use MACH11?
P
H
RR
S
S S
CC
C based
Clients
Java
based
Clients
JDBC
sqli
drda
drda
sqli
App Servers
and
applications
Websphere
BEA
JBoss
9. - 9 -
International Informix Users Group.2009 IIUG Informix Conference 9
What’s the motivation to move to MACH11?
• High Availability
New options
Flexibility
• Scale out
Analyze the load
Read-write ratios
10. - 10 -
International Informix Users Group.2009 IIUG Informix Conference 10
What do you get in Primary that
you don’t in SDS or RSS?
• Available only on the primary:
CREATE TABLE, CREATE INDEX and
most CREATE statements
UPDATE STATISTICS
TRUNCATE TABLE
ALTERS
XA Transactions
All isolation levels
Datablade Registration
• Do the application setup using an SLA connecting ONLY to
PRIMARY
P
S
U
H
R
11. - 11 -
International Informix Users Group.2009 IIUG Informix Conference 11
What do you get in Primary that
you don’t in SDS or RSS?
• Available in SDS, RSS, HDR Secondary
Updates via secondary notes are available only
if you set UPDATABLE_SECONDARY in onconfig.
SELECT, INSERT, UPDATE, DELETE
EXECUTE FUNCTION, EXECUTE PROCEDURE
CREATE TEMP TABLE
SELECT… INTO TEMP
CREATE INDEX, TRUNCATE on TEMP table
Limited Isolation levels
• DIRTY READ, COMMITTED READ, COMMITTED READ LAST
COMMITTED
P
S
U
H
R
12. - 12 -
International Informix Users Group.2009 IIUG Informix Conference 12
How do check which server I’m on?
• The tables below in sysmasterhas information you can use to get
environment information.
sysha_type
• Is a single row table with current HA server type
and its PRIMARY’s name.
sysha_workload
sysha_lagtime
• If MACH11 environment is setup, sysha database will be created.
Sysha database has complete configuration details
P
S
U
H
R
13. - 13 -
International Informix Users Group.2009 IIUG Informix Conference 13
How do check which server I’m on?
Create function mysrvrtype() returns char(1)
Define x int;
Select ha_type into x from sysha:sysha_type;
If (ha_type = 0) then
return ‘N’;
Elif (ha_type = 1) then
return ‘P’;
Elif (ha_type = 2) then
return ‘H’;
Elif (ha_type = 3) then
return ‘S’;
Elif (ha_type = 4) then
return ‘R’;
ELSE
return ‘E’; -- error
End if;
End function;
• Sysha_type.ha_primary stores the primary’s server name.
• Syssmaster:syssqlhosts has the details on the primary server.
P
S
U
H
R
14. - 14 -
International Informix Users Group.2009 IIUG Informix Conference 14
OK. I have MACH11. How do I failover my
application?
• Scenario 1. Simple configuration.
P
S
U
H
15. - 15 -
International Informix Users Group.2009 IIUG Informix Conference 15
OK. I have MACH11. How do I failover my
application?
• Scenario 1. Simple configuration.
P
S
U
H
16. - 16 -
International Informix Users Group.2009 IIUG Informix Conference 16
OK. I have MACH11. How do I failover my
application?
• Scenario 1. Simple configuration.
P
S
U
H
P
• Connection failover can be done in multiple ways,
depending on the application.
17. - 17 -
International Informix Users Group.2009 IIUG Informix Conference 17
S
P
U
H
P
OK. I have MACH11. How do I failover my
application?
• Typically error you get is -25582
• Option 1: Informix drivers on SQLI protocol
Using DBPATH
ksh_lenexa onsoctcp flins soc_lenexa g=ordmgmt
ksh_chicago onsoctcp flins soc_chicago g=ordmgmt
ksh_dallas onsoctcp flins soc_dallas g=ordmgmt
Usually you set INFORMIXSERVER=ksh_lenexa to connect
You can set DBPATH=//ksh_chicago://ksh_dallas
Use Connect to mydb and don’t specify any server name.
Order of reconnection attempt will be, INFORMIXSERVER,
servers in DBPATH.
18. - 18 -
International Informix Users Group.2009 IIUG Informix Conference 18
ordmgmt
group
S
P
U
H
P
OK. I have MACH11. How do I failover my
application?
• Typically error you get is -25582
• Option 2: Informix drivers on SQLI protocol
Connect to a group instead of a server
ordmgmt group - - i=2390
ksh_lenexa onsoctcp flins ksh_fc5 g=ordmgmt
ksh_chicago onsoctcp flins ksh_fc5s1 g=ordmgmt
ksh_dallas onsoctcp flins ksh_fc5s2 g=ordmgmt
Instead connect to mydb@ksh_lenexa do: connect to mydb@ordmgmt
Group names can be used in JDBC when you use sqlhosts
Connecting to a group will always connect to a PRIMARY server
To connect to a SDS, HDR Secondary or RSS node, connect to them
directly.
If you have multiple SDS, RSS nodes, you can group them separately.
19. - 19 -
International Informix Users Group.2009 IIUG Informix Conference 19
ordmgmt
S
P
U
H
P
OK. I have MACH11. How do I failover my
application?
• Typically error you get is -25582
• Option 3: Informix drivers on SQLI protocol
Use connection Manager
• SETUP THE SLA (Service Level Agreement)
• Simply connect to connection manager
Connect to rdb@ordconnmgr;
Connection manager is aware of the servers and will
automatically redirect the connection – no programming
required – to appropriate server.
C
20. - 20 -
International Informix Users Group.2009 IIUG Informix Conference 20
S
P
H
What’s connection manager?
• Connection Manager is one of those know-it-all types
• Applications first connect to connection manager
C
S
R
U
SLA
Application will first
connect to connection
manager
21. - 21 -
International Informix Users Group.2009 IIUG Informix Conference 21
S
P
H
What’s connection manager?
• Connection Manager is one of those know-it-all types
• Applications first connect to connection manager
C
S
R
U
SLA
Connection is redirected
to target server depending
on the SLA
22. - 22 -
International Informix Users Group.2009 IIUG Informix Conference 22
S
P
H
What’s connection manager?
• Connection Manager is one of those know-it-all types
• Applications first connect to connection manager
C
S
R
U
SLA
P
Primary goes off-line. An SDS
server will take over the
Primary role
23. - 23 -
International Informix Users Group.2009 IIUG Informix Conference 23
S
P
H
What’s connection manager?
• Connection Manager is one of those know-it-all types
• Applications first connect to connection manager
C
S
R
U
SLA
P
Application/Driver will
come back to connection
manager to get a new
connection
24. - 24 -
International Informix Users Group.2009 IIUG Informix Conference 24
S
P
H
What’s connection manager?
• Connection Manager is one of those know-it-all types
• Applications first connect to connection manager
C
S
R
U
SLA
P
Application will get the new
connection to the new
primary
25. - 25 -
International Informix Users Group.2009 IIUG Informix Conference 25
S
P
H
C
S
R
U
SL
A
Phmmm.. What’s SLA?
• Service Level Agreement to set at
connection manager
• Values: combinations of Primary, SDS, HDR, RSS, any server
SLA order=Primary+SDS
SLA Reports=RSS
SLA weekend=slowbox
order onsoctcp ordermc.my.com 13452
ordersds onsoctcp ordersds.my.com 13453
Reportrss onsoctcp reports.my.com 5728
slowbox onsoctcp oldbox.my.com 2848
26. - 26 -
International Informix Users Group.2009 IIUG Informix Conference 26
S
P
H
C
S
R
U
SLA
P
Does DRDA work with connection Manager?
• Yes
• Connection manager can be used with
all IDS drivers. Both SQLI and DRDA drivers support it.
• Simply use the connection manager ip and port on
any of the drivers.
27. - 27 -
International Informix Users Group.2009 IIUG Informix Conference 27
S
P
H
C
S
R
U
SLA
P
Can the rerouting be automatic?
• In APIs based on SQLI, the application layer
has to catch the connection exception and RETRY.
If using connection manager:
• Retry the connection back to the connection manager
• Connection manager will find the most appropriate server
based on SLA
• Connection manager knows the latest status of each server
If not using connection manager:
• Reconnecting to the group will connect to the PRIMARY
server
• DBPATH or a private list will simply get a new connection to
an available server.
28. - 28 -
International Informix Users Group.2009 IIUG Informix Conference 28
S
P
H
C
S
R
U
SL
A
P
Can the rerouting be automatic?
• Yes
• DRDA drivers have a feature called
Automatic Client Rerouting
• Supported in JDBC and .NET
IBM Data Server Driver for JDBC
IBM Data Server provider for .NET
• Simply use connection managers’s host and port number
• The driver, transparent to application, detects the connection
failure and reconnects to the available server.
• You can create list of alternate servers on JNDI
ds.setDriverType(4);
ds.setServerName(“srvr1.mydomain.com");
ds.setPortNumber("50002");
ds.setClientRerouteAlternateServerName(“srvr2.mydomain.com");
ds.setClientRerouteAlternatePortNumber("50000");
29. - 29 -
International Informix Users Group.2009 IIUG Informix Conference 29
S
P
H
C
S
R
U
SLA
P
Can the rerouting be automatic?
// Create a starting context for naming operations
InitialContext registry = new InitialContext();
// Create a DB2ClientRerouteServerList object
DB2ClientRerouteServerList address = new DB2ClientRerouteServerList();
// Set the port number and server name for the main Configuration Manager
address.setPrimaryPortNumber(50002);
address.setPrimaryServerName(“srvr2.mydomain.com");
// Set the port number and server name for the alternative Configuration Manager
int[] port = {50000};
String[] server = {“srvr1.mydomain.com"};
address.setAlternatePortNumber(port);
address.setAlternateServerName(server);
registry.rebind("serverList", address);
// Assign the JNDI name of the DB2ClientRerouteServerList object to the
// clientRerouteServerListJNDIName property
datasource.setClientRerouteServerListJNDIName("serverList");
• After the connection is reestablished, the driver throws a SQLException with
error code -4498. Failure to reconnect will return -4499.
• You’ll need to handle this exception and restart the current transction.
• The open transaction at the server is automatically rolledback.
30. - 30 -
International Informix Users Group.2009 IIUG Informix Conference 30
How can I deploy MACH11 for
load balancing?
• Connection Manager automatically
load balances at the connection level
• CM knows the load on each of the servers and
redirects the connection to least loaded server within SLA
• IBM Data Server driver for JDBC also has transaction level
load balancing.
• The driver and the server exchange the current load on all
systems within the SLA
• The load information is exchanged at connection time and
every 8 seconds.
• Driver assigns the connection for each transaction
S
P
H
C
S
R
U
SLA
P
31. - 31 -
International Informix Users Group.2009 IIUG Informix Conference 31
How do I use transaction
load balancing?
• Set the proprerty enableSysplexWLB to true
• Set maxTransportObjects – to maximum number of
connections
• Can be set in the driver or a custom datasource
property in Websphere.
• Connection Manager automatically assigns the
server/connection with least load to perform the transaction.
S
P
H
C
S
R
U
SLA
P
32. - 32 -
International Informix Users Group.2009 IIUG Informix Conference 32
Thank You
rkeshav@us.ibm.com