SlideShare a Scribd company logo
1 of 46
Download to read offline
ASNApalooza2007ASNApalooza2007
by Roger Pence
ASNA Education Director
Maximum velocity: How to get theMaximum velocity: How to get the
most performance from your AVRmost performance from your AVR
appsapps
Paying attention to just a few details
can make your programs faster and
more efficient
1
ASNApalooza2007ASNApalooza2007
Overview of topicsOverview of topics
• Use connection pooling to improve file IO
performance
• Using the singleton DB pattern
• Beware shared DB’s
• Using threading to improve performance
2
ASNApalooza2007ASNApalooza2007
The proper use of
connection pooling
No single thing will more improve Web
application performance that proper use of
connection pooling
ASNApalooza2007ASNApalooza2007
What is connection pooling?What is connection pooling?
• Connection pooling is DataGate’s ability to
“reuse” database server jobs between
stateless IO requests
• Connection pooling applies mostly to stateless
Web applications or Web services.
• Rarely is connection pooling helpful to
Windows-based programs
– It’s not likely to hurt anything, but connection
pooling is especially suited for stateless apps
ASNApalooza2007ASNApalooza2007
Connection pooling: the System iConnection pooling: the System i
• Effective connection pooling is especially
important if the System i is your database
platform
• Without connection pooling, a new OS/400 job
must be created for each request. This can take
3-10 seconds—depending on System i load and
configuration
• With connection pooling, an OS/400 job is made
available to a request in a matter of milliseconds
ASNApalooza2007ASNApalooza2007
Connection pooling: SQL ServerConnection pooling: SQL Server
• Although instancing a database connection isn’t
quite the performance drain on SQL Server that it
is on the System i, it’s still a drain
• It may also positively effect SQL Server licensing
– Because you are in effect also pooling licensing (for
CAL-based licenses)
– Connection pooling keeps any one connection is play
for the minimum amount of time
• This discussion is primarily System i-centric, but
everything said here about connection pooling
also applies to DataGate for SQL Server
ASNApalooza2007ASNApalooza2007
Enabling connection poolingEnabling connection pooling
• Connection pooling can be enabled statically
through database name attributes
• Or set dynamically through changing the
database object’s PoolingTimeOut property
prior to connecting that object
ASNApalooza2007ASNApalooza2007
Enabling connection pooling staticallyEnabling connection pooling statically
• Connection pooling is enabled with the
DataGate Database Manager’s “Work with
Database Names”panel
ASNApalooza2007ASNApalooza2007
Enabling connection poolingEnabling connection pooling
dynamicallydynamically
• Connection pooling can also be controlled by
setting the database object’s PoolingTimeout
value.
• Any value greater than zero sets the connection
pooling timeout value (in minutes); zero disables
connection pooling
ASNApalooza2007ASNApalooza2007
What’s a good time-out value?What’s a good time-out value?
• That depends.
• For many shops, something in the range of 20
minutes or so works well
• However, we have customers that use much
larger values if the latency between pages is
extreme
– Shop floor browser-based applications for
example
ASNApalooza2007ASNApalooza2007
How does connection pooling it work?How does connection pooling it work?
• Red zone= inactive pooled jobs
• Green zone = active jobs
• At this point, application has no jobs pooled
ASNApalooza2007ASNApalooza2007
Blue and pink: cool and warmBlue and pink: cool and warm
• For purposes of this discussion:
– Blue users get new, previously unpooled jobs.
These uses wait 3-7 seconds for their page.
– Blue jobs are new, previously unpooled jobs.
– Pink users get a pooled job. These users wait just
a few milliseconds for their page.
– Pink jobs are previously pooled jobs.
Think of it this way, blue users/jobs are cool;
pink users/jobs are warm!
ASNApalooza2007ASNApalooza2007
A user request occursA user request occurs
• DataGate first looks in the red job zone for a
previously pooled job. There isn’t one. DataGate
starts a new one.
ASNApalooza2007ASNApalooza2007
The job is now pooledThe job is now pooled
• When the server is done servicing the user’s request,
the job is “moved” to the pooled zone
• Pooled jobs have no open files, no activity, and
consume very few OS/400 resources
ASNApalooza2007ASNApalooza2007
Same user requests a second pageSame user requests a second page
• Because there is a job in the pooled zone, that job is
made available in just a few milliseconds
ASNApalooza2007ASNApalooza2007
The job is put back in the poolThe job is put back in the pool
• When the server is done servicing the user’s request,
the job is “moved” to the pooled zone again
ASNApalooza2007ASNApalooza2007
Two users request a page within 1 MSTwo users request a page within 1 MS
of each otherof each other
• The first user gets the previously pooled job
• The second user has to wait for OS/400 to create a
new job
ASNApalooza2007ASNApalooza2007
Now two jobs are pooledNow two jobs are pooled
• Two jobs are pooled
• With two jobs pooled, the two users are both
guaranteed a pooled job
ASNApalooza2007ASNApalooza2007
Three users request a page within aThree users request a page within a
couple of MS of each othercouple of MS of each other
• Two user get a pooled job; the third user waits for a new job
• For most Web apps, jobs aren’t unique to a user, so the two
pooled jobs are avaiable to the first two users—independent
of who previously used the two pooled jobs
ASNApalooza2007ASNApalooza2007
Now three jobs are pooledNow three jobs are pooled
• The inactive job pool is now somewhat populated
• Lots of users can come and go through these
three jobs
ASNApalooza2007ASNApalooza2007
The benefit of a populated pooledThe benefit of a populated pooled
zonezone
• As the pooled zone gets populated, it less
likely that new jobs will be needed
• After get five or six pooled, what are the
chances that five or six users will each request
a page within a few hundred or so
milliseconds of each other?
• Of course, it could happen. And if it does, a
new job is added and the pooled zone grows
by one
ASNApalooza2007ASNApalooza2007
20 or 30 to one!20 or 30 to one!
• ASNA benchmarks show that you can expect
at least 20 or 30 users able to do “normal”
work using a single pooled job
• As the load grows, so grows the pooled zone
• But pooled jobs have a very low impact on the
System i
22
Lots of users busy with few jobs
ASNApalooza2007ASNApalooza2007
How does the pooled zone get clearedHow does the pooled zone get cleared
outout
• By job timeout value
– First in, first out
• For example with no activity, a job drops out of the
pooled zone when its timeout value expires
ASNApalooza2007ASNApalooza2007
How to tell if it’s workingHow to tell if it’s working
• Performance is a very good way to tell if
connection pooling is working
• However, another wau to ensure it’s working
is to test you’re app, through several pages,
knowing only one user is using it
• If, after using the app for a while you have
more than one OS/400 job active, something
is amiss
24
Something is wrong here!
There are three jobs for a
application with a single user!
ASNApalooza2007ASNApalooza2007
Something else to watch forSomething else to watch for
• It’s possible to be using connection pooling
correctly and still get more than one job active
• This can happen when a Web page uses one
or more secondary classes where each of
which establishes its own DB connection
• This topic is out of the scope of this
presentation, but if you think this is happening
to you, ask me offline for a copy of the
Singleton DB pattern explanation
26
ASNApalooza2007ASNApalooza2007
The rules of connection poolingThe rules of connection pooling
• Enable it either statically or dynamically
• The next point is very important!
• Each page must following this cycle:
– Connect the DB
– Open files
– Do work
– Close files
– Disconnect the DB
27
ASNApalooza2007ASNApalooza2007
Your app must disconnect for everyYour app must disconnect for every
page!page!
• A job gets moved back to the pooled zone
when it’s disconnect
• If you don’t disconnect, you aren’t pooling
jobs!
• The Page’s Unload event is a good place to put
your closes and disconnect
28
ASNApalooza2007ASNApalooza2007
Consider doing this:Consider doing this:
• Use Close *All to close all files
– This gracefully closes all open files
– Doesn’t choke if none are opened
• Then disconnect
29
ASNApalooza2007ASNApalooza2007
Don’t forget to close files!Don’t forget to close files!
• If you disconnect but don’t close files, you
cause lots of files
to be opened!
• Close *All
• then disconnect
30
ASNApalooza2007ASNApalooza2007
Remember this!Remember this!
• If you don’t close files and disconnect the DB
object before the page goes out of scope, you
are not using connection pooling!
• The same advice applies to Web methods.
Close files and disconnect the DB after every
Web method call
31
ASNApalooza2007ASNApalooza2007
Your app must disconnect for everyYour app must disconnect for every
page!page!
• A job gets moved back to the pooled zone
when it’s disconnected
• If you don’t disconnect, it’s an orphan active
job
32
ASNApalooza2007ASNApalooza2007
Pooled connection scopePooled connection scope
• Pooled connections are uniquely identified by
all of the properties of a database name.
• Thus, if each user is signing on to your Web
app with her user profile and password, you
are negating the scalable benefits of
connection pooling
– You are however, letting users get their jobs back
quickly
33
ASNApalooza2007ASNApalooza2007
Pooled connection scopePooled connection scope
• Some shops can’t use a single database name
for all users (ie, a single user ID and
password). Thanks SOX.
• Consider using three or database names to
group users (perhaps by security or function)
• This way you’re at least getting some
scalability by letting each group share pooled
jobs
34
ASNApalooza2007ASNApalooza2007
Limiting database platform jobsLimiting database platform jobs
• When you instance a class that has a DB
object, and that class connects, that class gets
its own job on the database platform
• This means that it’s very easy for any one
program (Windows or Web) to have several
jobs in play for that one program
• This… is not good!
35
ASNApalooza2007ASNApalooza2007
Limiting database platform jobsLimiting database platform jobs
• Note the following discussion applies to
Windows and Web AVR apps, but not to
Monarch-generated apps
36
ASNApalooza2007ASNApalooza2007
An example with two classesAn example with two classes
• Two classes, two DBs, two connects = two jobs
37
This is especially
troubling on the
System i.
Scalability goes
out the window
if you aren’t
careful!
ASNApalooza2007ASNApalooza2007
The solution: the singleton DB patternThe solution: the singleton DB pattern
• A parent class
passes its job
to its children,
the children to
their children
• Results in just
one job for the
instance of the
program
38
ASNApalooza2007ASNApalooza2007
The bad scenarioThe bad scenario
• Here both
classes get
their job
• This
effects
Windows
and Web
programs
39
40
To limit the database platform one job, the parent
class needs to pass its DB object around to its
children (and them to their children if they have any.
ASNApalooza2007ASNApalooza2007
There are just a few rulesThere are just a few rules
• The parent, top level class, must pass its DB
object on
• The parent must disconnect the DB
• Child can never disconnect
– Others might want the job
• Children can connection the DB, but should
check to see if it needs to be
– Others might have previously connected it
41
ASNApalooza2007ASNApalooza2007
The singleton DB pattern is well-The singleton DB pattern is well-
documenteddocumented
• The downloads for Palooza (associated with
this session) includes a detailed description of
the singleton DB pattern
• Factor it into all of your programs!
• If you don’t, you are risking scalability on your
database server
42
ASNApalooza2007ASNApalooza2007
Beware shared DB connections!Beware shared DB connections!
• Do not share DB connections in Web
applications
• This forces all users to wait on a single thread
for DB connections
• This is guaranteed to make you stay up late at
night
43
ASNApalooza2007ASNApalooza2007
Consider (carefully) if using threadingConsider (carefully) if using threading
can help your application performancecan help your application performance
• Spinning off certain processes can help
application performance
• One place where using threading is effective is
to cause Web services to fire off a thread (to
start a long-running process) and quickly
return
• Here is an abbreviated example…
Spinning off the SubmitPrint process on its own thread.
ASNApalooza2007ASNApalooza2007
In summaryIn summary
• Use connection pooling. Properly!
• Dispatch the KeyList where it makes sense
• Use SetRange/ReadRange instead of
SETLL/READE
• Populate lists from read-only files
• Don’t persist record locks longer than
necessary
46

More Related Content

What's hot

High Performance Mobile Web
High Performance Mobile WebHigh Performance Mobile Web
High Performance Mobile WebJames D Bloom
 
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQL
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQLFrom Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQL
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQLKonstantin Gredeskoul
 
High Performance Mobile Web
High Performance Mobile WebHigh Performance Mobile Web
High Performance Mobile WebJames D Bloom
 
World-class Data Engineering with Amazon Redshift
World-class Data Engineering with Amazon RedshiftWorld-class Data Engineering with Amazon Redshift
World-class Data Engineering with Amazon RedshiftLars Kamp
 
RESTful Approaches to Financial Systems Integration
RESTful Approaches to Financial Systems IntegrationRESTful Approaches to Financial Systems Integration
RESTful Approaches to Financial Systems IntegrationKirkWylie
 
50 Shades of Fail KScope16
50 Shades of Fail KScope1650 Shades of Fail KScope16
50 Shades of Fail KScope16Christian Berg
 
Ultimate Free SQL Server Toolkit
Ultimate Free SQL Server ToolkitUltimate Free SQL Server Toolkit
Ultimate Free SQL Server ToolkitKevin Kline
 
Your Guide to Streaming - The Engineer's Perspective
Your Guide to Streaming - The Engineer's PerspectiveYour Guide to Streaming - The Engineer's Perspective
Your Guide to Streaming - The Engineer's PerspectiveIlya Ganelin
 
LearnBop Blue Green AWS Deployments - October 2015
LearnBop Blue Green AWS Deployments - October 2015LearnBop Blue Green AWS Deployments - October 2015
LearnBop Blue Green AWS Deployments - October 2015Alec Lazarescu
 
Deployment pipeline for Azure SQL Databases
Deployment pipeline for Azure SQL DatabasesDeployment pipeline for Azure SQL Databases
Deployment pipeline for Azure SQL DatabasesEduardo Piairo
 
Divide and conquer in the cloud
Divide and conquer in the cloudDivide and conquer in the cloud
Divide and conquer in the cloudJustin Swanhart
 
Shopzilla - Performance By Design
Shopzilla - Performance By DesignShopzilla - Performance By Design
Shopzilla - Performance By DesignTim Morrow
 
Mobile Web Best Practices
Mobile Web Best PracticesMobile Web Best Practices
Mobile Web Best PracticesJames D Bloom
 
Hadoop at Meebo: Lessons in the Real World
Hadoop at Meebo: Lessons in the Real WorldHadoop at Meebo: Lessons in the Real World
Hadoop at Meebo: Lessons in the Real Worldvoberoi
 
Building faster websites: web performance with WordPress
Building faster websites: web performance with WordPressBuilding faster websites: web performance with WordPress
Building faster websites: web performance with WordPressJohannes Siipola
 
Top 10 Application Problems
Top 10 Application ProblemsTop 10 Application Problems
Top 10 Application ProblemsAppDynamics
 
Lessons from Highly Scalable Architectures at Social Networking Sites
Lessons from Highly Scalable Architectures at Social Networking SitesLessons from Highly Scalable Architectures at Social Networking Sites
Lessons from Highly Scalable Architectures at Social Networking SitesPatrick Senti
 

What's hot (20)

High Performance Mobile Web
High Performance Mobile WebHigh Performance Mobile Web
High Performance Mobile Web
 
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQL
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQLFrom Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQL
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQL
 
High Performance Mobile Web
High Performance Mobile WebHigh Performance Mobile Web
High Performance Mobile Web
 
World-class Data Engineering with Amazon Redshift
World-class Data Engineering with Amazon RedshiftWorld-class Data Engineering with Amazon Redshift
World-class Data Engineering with Amazon Redshift
 
RESTful Approaches to Financial Systems Integration
RESTful Approaches to Financial Systems IntegrationRESTful Approaches to Financial Systems Integration
RESTful Approaches to Financial Systems Integration
 
Salesforce Performance hacks - Client Side
Salesforce Performance hacks - Client SideSalesforce Performance hacks - Client Side
Salesforce Performance hacks - Client Side
 
50 Shades of Fail KScope16
50 Shades of Fail KScope1650 Shades of Fail KScope16
50 Shades of Fail KScope16
 
Ultimate Free SQL Server Toolkit
Ultimate Free SQL Server ToolkitUltimate Free SQL Server Toolkit
Ultimate Free SQL Server Toolkit
 
Your Guide to Streaming - The Engineer's Perspective
Your Guide to Streaming - The Engineer's PerspectiveYour Guide to Streaming - The Engineer's Perspective
Your Guide to Streaming - The Engineer's Perspective
 
LearnBop Blue Green AWS Deployments - October 2015
LearnBop Blue Green AWS Deployments - October 2015LearnBop Blue Green AWS Deployments - October 2015
LearnBop Blue Green AWS Deployments - October 2015
 
Deployment pipeline for Azure SQL Databases
Deployment pipeline for Azure SQL DatabasesDeployment pipeline for Azure SQL Databases
Deployment pipeline for Azure SQL Databases
 
Divide and conquer in the cloud
Divide and conquer in the cloudDivide and conquer in the cloud
Divide and conquer in the cloud
 
Shopzilla - Performance By Design
Shopzilla - Performance By DesignShopzilla - Performance By Design
Shopzilla - Performance By Design
 
Mobile Web Best Practices
Mobile Web Best PracticesMobile Web Best Practices
Mobile Web Best Practices
 
Hadoop at Meebo: Lessons in the Real World
Hadoop at Meebo: Lessons in the Real WorldHadoop at Meebo: Lessons in the Real World
Hadoop at Meebo: Lessons in the Real World
 
Building faster websites: web performance with WordPress
Building faster websites: web performance with WordPressBuilding faster websites: web performance with WordPress
Building faster websites: web performance with WordPress
 
Top 10 Application Problems
Top 10 Application ProblemsTop 10 Application Problems
Top 10 Application Problems
 
Virtualization and Containers
Virtualization and ContainersVirtualization and Containers
Virtualization and Containers
 
Lessons from Highly Scalable Architectures at Social Networking Sites
Lessons from Highly Scalable Architectures at Social Networking SitesLessons from Highly Scalable Architectures at Social Networking Sites
Lessons from Highly Scalable Architectures at Social Networking Sites
 
Running Yarn at Scale
Running Yarn at Scale Running Yarn at Scale
Running Yarn at Scale
 

Similar to Using connection pooling for better AVR Web performance

Report from the Field on the PostgreSQL-compatible Edition of Amazon Aurora -...
Report from the Field on the PostgreSQL-compatible Edition of Amazon Aurora -...Report from the Field on the PostgreSQL-compatible Edition of Amazon Aurora -...
Report from the Field on the PostgreSQL-compatible Edition of Amazon Aurora -...Amazon Web Services
 
DAT316_Report from the field on Aurora PostgreSQL Performance
DAT316_Report from the field on Aurora PostgreSQL PerformanceDAT316_Report from the field on Aurora PostgreSQL Performance
DAT316_Report from the field on Aurora PostgreSQL PerformanceAmazon Web Services
 
adap-stability-202310.pptx
adap-stability-202310.pptxadap-stability-202310.pptx
adap-stability-202310.pptxMichael Ming Lei
 
DOES SFO 2016 - Chris Fulton - CD for DBs
DOES SFO 2016 - Chris Fulton - CD for DBsDOES SFO 2016 - Chris Fulton - CD for DBs
DOES SFO 2016 - Chris Fulton - CD for DBsGene Kim
 
Workshop on Advanced Design Patterns for Amazon DynamoDB - DAT405 - re:Invent...
Workshop on Advanced Design Patterns for Amazon DynamoDB - DAT405 - re:Invent...Workshop on Advanced Design Patterns for Amazon DynamoDB - DAT405 - re:Invent...
Workshop on Advanced Design Patterns for Amazon DynamoDB - DAT405 - re:Invent...Amazon Web Services
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1ScyllaDB
 
Scaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersScaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersAmazon Web Services
 
20141206 4 q14_dataconference_i_am_your_db
20141206 4 q14_dataconference_i_am_your_db20141206 4 q14_dataconference_i_am_your_db
20141206 4 q14_dataconference_i_am_your_dbhyeongchae lee
 
Nosql-Module 1 PPT.pptx
Nosql-Module 1 PPT.pptxNosql-Module 1 PPT.pptx
Nosql-Module 1 PPT.pptxRadhika R
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQLKonstantin Gredeskoul
 
IBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and ExpansionIBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and ExpansionLetsConnect
 
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...Amazon Web Services
 
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarGeek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarIDERA Software
 
New availability features in oracle rac 12c release 2 anair ss
New availability features in oracle rac 12c release 2 anair   ssNew availability features in oracle rac 12c release 2 anair   ss
New availability features in oracle rac 12c release 2 anair ssAnil Nair
 
SAP Open Source meetup/Speedment - Palo Alto 2015
SAP Open Source meetup/Speedment - Palo Alto 2015SAP Open Source meetup/Speedment - Palo Alto 2015
SAP Open Source meetup/Speedment - Palo Alto 2015Speedment, Inc.
 

Similar to Using connection pooling for better AVR Web performance (20)

Report from the Field on the PostgreSQL-compatible Edition of Amazon Aurora -...
Report from the Field on the PostgreSQL-compatible Edition of Amazon Aurora -...Report from the Field on the PostgreSQL-compatible Edition of Amazon Aurora -...
Report from the Field on the PostgreSQL-compatible Edition of Amazon Aurora -...
 
DAT316_Report from the field on Aurora PostgreSQL Performance
DAT316_Report from the field on Aurora PostgreSQL PerformanceDAT316_Report from the field on Aurora PostgreSQL Performance
DAT316_Report from the field on Aurora PostgreSQL Performance
 
Amazon Aurora (Debanjan Saha) - AWS DB Day
Amazon Aurora (Debanjan Saha) - AWS DB DayAmazon Aurora (Debanjan Saha) - AWS DB Day
Amazon Aurora (Debanjan Saha) - AWS DB Day
 
MongoDB
MongoDBMongoDB
MongoDB
 
adap-stability-202310.pptx
adap-stability-202310.pptxadap-stability-202310.pptx
adap-stability-202310.pptx
 
DOES SFO 2016 - Chris Fulton - CD for DBs
DOES SFO 2016 - Chris Fulton - CD for DBsDOES SFO 2016 - Chris Fulton - CD for DBs
DOES SFO 2016 - Chris Fulton - CD for DBs
 
Workshop on Advanced Design Patterns for Amazon DynamoDB - DAT405 - re:Invent...
Workshop on Advanced Design Patterns for Amazon DynamoDB - DAT405 - re:Invent...Workshop on Advanced Design Patterns for Amazon DynamoDB - DAT405 - re:Invent...
Workshop on Advanced Design Patterns for Amazon DynamoDB - DAT405 - re:Invent...
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
 
Scaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersScaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million Users
 
Background processing with hangfire
Background processing with hangfireBackground processing with hangfire
Background processing with hangfire
 
20141206 4 q14_dataconference_i_am_your_db
20141206 4 q14_dataconference_i_am_your_db20141206 4 q14_dataconference_i_am_your_db
20141206 4 q14_dataconference_i_am_your_db
 
Nosql-Module 1 PPT.pptx
Nosql-Module 1 PPT.pptxNosql-Module 1 PPT.pptx
Nosql-Module 1 PPT.pptx
 
12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL12-Step Program for Scaling Web Applications on PostgreSQL
12-Step Program for Scaling Web Applications on PostgreSQL
 
NoSQL Evolution
NoSQL EvolutionNoSQL Evolution
NoSQL Evolution
 
IBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and ExpansionIBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and Expansion
 
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
 
Hadoop availability
Hadoop availabilityHadoop availability
Hadoop availability
 
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarGeek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
 
New availability features in oracle rac 12c release 2 anair ss
New availability features in oracle rac 12c release 2 anair   ssNew availability features in oracle rac 12c release 2 anair   ss
New availability features in oracle rac 12c release 2 anair ss
 
SAP Open Source meetup/Speedment - Palo Alto 2015
SAP Open Source meetup/Speedment - Palo Alto 2015SAP Open Source meetup/Speedment - Palo Alto 2015
SAP Open Source meetup/Speedment - Palo Alto 2015
 

More from Roger Pence

Stop validating user input like a rookie
Stop validating user input like a rookieStop validating user input like a rookie
Stop validating user input like a rookieRoger Pence
 
What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013Roger Pence
 
All you know about ASP.NET deployment is wrong!
All you know about ASP.NET deployment is wrong!All you know about ASP.NET deployment is wrong!
All you know about ASP.NET deployment is wrong!Roger Pence
 
Using formal testing to make better AVR apps
Using formal testing to make better AVR appsUsing formal testing to make better AVR apps
Using formal testing to make better AVR appsRoger Pence
 
Strategic guidance
Strategic guidanceStrategic guidance
Strategic guidanceRoger Pence
 
Fixing an annoying GridView problem
Fixing an annoying GridView problemFixing an annoying GridView problem
Fixing an annoying GridView problemRoger Pence
 

More from Roger Pence (7)

Stop validating user input like a rookie
Stop validating user input like a rookieStop validating user input like a rookie
Stop validating user input like a rookie
 
What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013What's new in AVR 12.0 and VS 2013
What's new in AVR 12.0 and VS 2013
 
All you know about ASP.NET deployment is wrong!
All you know about ASP.NET deployment is wrong!All you know about ASP.NET deployment is wrong!
All you know about ASP.NET deployment is wrong!
 
Browser tools
Browser toolsBrowser tools
Browser tools
 
Using formal testing to make better AVR apps
Using formal testing to make better AVR appsUsing formal testing to make better AVR apps
Using formal testing to make better AVR apps
 
Strategic guidance
Strategic guidanceStrategic guidance
Strategic guidance
 
Fixing an annoying GridView problem
Fixing an annoying GridView problemFixing an annoying GridView problem
Fixing an annoying GridView problem
 

Recently uploaded

Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsJaydeep Chhasatia
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfBrain Inventory
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?AmeliaSmith90
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntelliSource Technologies
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeNeo4j
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxAutus Cyber Tech
 
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine HarmonyLeveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmonyelliciumsolutionspun
 
Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxJoão Esperancinha
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Jaydeep Chhasatia
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...OnePlan Solutions
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native BuildpacksVish Abrams
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilVICTOR MAESTRE RAMIREZ
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampVICTOR MAESTRE RAMIREZ
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionsNirav Modi
 
Enterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze IncEnterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze Incrobinwilliams8624
 

Recently uploaded (20)

Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdf
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptx
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptx
 
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine HarmonyLeveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
 
Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptx
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native Buildpacks
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-Council
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - Datacamp
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspections
 
Enterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze IncEnterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze Inc
 
Salesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptxSalesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptx
 

Using connection pooling for better AVR Web performance

  • 1. ASNApalooza2007ASNApalooza2007 by Roger Pence ASNA Education Director Maximum velocity: How to get theMaximum velocity: How to get the most performance from your AVRmost performance from your AVR appsapps Paying attention to just a few details can make your programs faster and more efficient 1
  • 2. ASNApalooza2007ASNApalooza2007 Overview of topicsOverview of topics • Use connection pooling to improve file IO performance • Using the singleton DB pattern • Beware shared DB’s • Using threading to improve performance 2
  • 3. ASNApalooza2007ASNApalooza2007 The proper use of connection pooling No single thing will more improve Web application performance that proper use of connection pooling
  • 4. ASNApalooza2007ASNApalooza2007 What is connection pooling?What is connection pooling? • Connection pooling is DataGate’s ability to “reuse” database server jobs between stateless IO requests • Connection pooling applies mostly to stateless Web applications or Web services. • Rarely is connection pooling helpful to Windows-based programs – It’s not likely to hurt anything, but connection pooling is especially suited for stateless apps
  • 5. ASNApalooza2007ASNApalooza2007 Connection pooling: the System iConnection pooling: the System i • Effective connection pooling is especially important if the System i is your database platform • Without connection pooling, a new OS/400 job must be created for each request. This can take 3-10 seconds—depending on System i load and configuration • With connection pooling, an OS/400 job is made available to a request in a matter of milliseconds
  • 6. ASNApalooza2007ASNApalooza2007 Connection pooling: SQL ServerConnection pooling: SQL Server • Although instancing a database connection isn’t quite the performance drain on SQL Server that it is on the System i, it’s still a drain • It may also positively effect SQL Server licensing – Because you are in effect also pooling licensing (for CAL-based licenses) – Connection pooling keeps any one connection is play for the minimum amount of time • This discussion is primarily System i-centric, but everything said here about connection pooling also applies to DataGate for SQL Server
  • 7. ASNApalooza2007ASNApalooza2007 Enabling connection poolingEnabling connection pooling • Connection pooling can be enabled statically through database name attributes • Or set dynamically through changing the database object’s PoolingTimeOut property prior to connecting that object
  • 8. ASNApalooza2007ASNApalooza2007 Enabling connection pooling staticallyEnabling connection pooling statically • Connection pooling is enabled with the DataGate Database Manager’s “Work with Database Names”panel
  • 9. ASNApalooza2007ASNApalooza2007 Enabling connection poolingEnabling connection pooling dynamicallydynamically • Connection pooling can also be controlled by setting the database object’s PoolingTimeout value. • Any value greater than zero sets the connection pooling timeout value (in minutes); zero disables connection pooling
  • 10. ASNApalooza2007ASNApalooza2007 What’s a good time-out value?What’s a good time-out value? • That depends. • For many shops, something in the range of 20 minutes or so works well • However, we have customers that use much larger values if the latency between pages is extreme – Shop floor browser-based applications for example
  • 11. ASNApalooza2007ASNApalooza2007 How does connection pooling it work?How does connection pooling it work? • Red zone= inactive pooled jobs • Green zone = active jobs • At this point, application has no jobs pooled
  • 12. ASNApalooza2007ASNApalooza2007 Blue and pink: cool and warmBlue and pink: cool and warm • For purposes of this discussion: – Blue users get new, previously unpooled jobs. These uses wait 3-7 seconds for their page. – Blue jobs are new, previously unpooled jobs. – Pink users get a pooled job. These users wait just a few milliseconds for their page. – Pink jobs are previously pooled jobs. Think of it this way, blue users/jobs are cool; pink users/jobs are warm!
  • 13. ASNApalooza2007ASNApalooza2007 A user request occursA user request occurs • DataGate first looks in the red job zone for a previously pooled job. There isn’t one. DataGate starts a new one.
  • 14. ASNApalooza2007ASNApalooza2007 The job is now pooledThe job is now pooled • When the server is done servicing the user’s request, the job is “moved” to the pooled zone • Pooled jobs have no open files, no activity, and consume very few OS/400 resources
  • 15. ASNApalooza2007ASNApalooza2007 Same user requests a second pageSame user requests a second page • Because there is a job in the pooled zone, that job is made available in just a few milliseconds
  • 16. ASNApalooza2007ASNApalooza2007 The job is put back in the poolThe job is put back in the pool • When the server is done servicing the user’s request, the job is “moved” to the pooled zone again
  • 17. ASNApalooza2007ASNApalooza2007 Two users request a page within 1 MSTwo users request a page within 1 MS of each otherof each other • The first user gets the previously pooled job • The second user has to wait for OS/400 to create a new job
  • 18. ASNApalooza2007ASNApalooza2007 Now two jobs are pooledNow two jobs are pooled • Two jobs are pooled • With two jobs pooled, the two users are both guaranteed a pooled job
  • 19. ASNApalooza2007ASNApalooza2007 Three users request a page within aThree users request a page within a couple of MS of each othercouple of MS of each other • Two user get a pooled job; the third user waits for a new job • For most Web apps, jobs aren’t unique to a user, so the two pooled jobs are avaiable to the first two users—independent of who previously used the two pooled jobs
  • 20. ASNApalooza2007ASNApalooza2007 Now three jobs are pooledNow three jobs are pooled • The inactive job pool is now somewhat populated • Lots of users can come and go through these three jobs
  • 21. ASNApalooza2007ASNApalooza2007 The benefit of a populated pooledThe benefit of a populated pooled zonezone • As the pooled zone gets populated, it less likely that new jobs will be needed • After get five or six pooled, what are the chances that five or six users will each request a page within a few hundred or so milliseconds of each other? • Of course, it could happen. And if it does, a new job is added and the pooled zone grows by one
  • 22. ASNApalooza2007ASNApalooza2007 20 or 30 to one!20 or 30 to one! • ASNA benchmarks show that you can expect at least 20 or 30 users able to do “normal” work using a single pooled job • As the load grows, so grows the pooled zone • But pooled jobs have a very low impact on the System i 22 Lots of users busy with few jobs
  • 23. ASNApalooza2007ASNApalooza2007 How does the pooled zone get clearedHow does the pooled zone get cleared outout • By job timeout value – First in, first out • For example with no activity, a job drops out of the pooled zone when its timeout value expires
  • 24. ASNApalooza2007ASNApalooza2007 How to tell if it’s workingHow to tell if it’s working • Performance is a very good way to tell if connection pooling is working • However, another wau to ensure it’s working is to test you’re app, through several pages, knowing only one user is using it • If, after using the app for a while you have more than one OS/400 job active, something is amiss 24
  • 25. Something is wrong here! There are three jobs for a application with a single user!
  • 26. ASNApalooza2007ASNApalooza2007 Something else to watch forSomething else to watch for • It’s possible to be using connection pooling correctly and still get more than one job active • This can happen when a Web page uses one or more secondary classes where each of which establishes its own DB connection • This topic is out of the scope of this presentation, but if you think this is happening to you, ask me offline for a copy of the Singleton DB pattern explanation 26
  • 27. ASNApalooza2007ASNApalooza2007 The rules of connection poolingThe rules of connection pooling • Enable it either statically or dynamically • The next point is very important! • Each page must following this cycle: – Connect the DB – Open files – Do work – Close files – Disconnect the DB 27
  • 28. ASNApalooza2007ASNApalooza2007 Your app must disconnect for everyYour app must disconnect for every page!page! • A job gets moved back to the pooled zone when it’s disconnect • If you don’t disconnect, you aren’t pooling jobs! • The Page’s Unload event is a good place to put your closes and disconnect 28
  • 29. ASNApalooza2007ASNApalooza2007 Consider doing this:Consider doing this: • Use Close *All to close all files – This gracefully closes all open files – Doesn’t choke if none are opened • Then disconnect 29
  • 30. ASNApalooza2007ASNApalooza2007 Don’t forget to close files!Don’t forget to close files! • If you disconnect but don’t close files, you cause lots of files to be opened! • Close *All • then disconnect 30
  • 31. ASNApalooza2007ASNApalooza2007 Remember this!Remember this! • If you don’t close files and disconnect the DB object before the page goes out of scope, you are not using connection pooling! • The same advice applies to Web methods. Close files and disconnect the DB after every Web method call 31
  • 32. ASNApalooza2007ASNApalooza2007 Your app must disconnect for everyYour app must disconnect for every page!page! • A job gets moved back to the pooled zone when it’s disconnected • If you don’t disconnect, it’s an orphan active job 32
  • 33. ASNApalooza2007ASNApalooza2007 Pooled connection scopePooled connection scope • Pooled connections are uniquely identified by all of the properties of a database name. • Thus, if each user is signing on to your Web app with her user profile and password, you are negating the scalable benefits of connection pooling – You are however, letting users get their jobs back quickly 33
  • 34. ASNApalooza2007ASNApalooza2007 Pooled connection scopePooled connection scope • Some shops can’t use a single database name for all users (ie, a single user ID and password). Thanks SOX. • Consider using three or database names to group users (perhaps by security or function) • This way you’re at least getting some scalability by letting each group share pooled jobs 34
  • 35. ASNApalooza2007ASNApalooza2007 Limiting database platform jobsLimiting database platform jobs • When you instance a class that has a DB object, and that class connects, that class gets its own job on the database platform • This means that it’s very easy for any one program (Windows or Web) to have several jobs in play for that one program • This… is not good! 35
  • 36. ASNApalooza2007ASNApalooza2007 Limiting database platform jobsLimiting database platform jobs • Note the following discussion applies to Windows and Web AVR apps, but not to Monarch-generated apps 36
  • 37. ASNApalooza2007ASNApalooza2007 An example with two classesAn example with two classes • Two classes, two DBs, two connects = two jobs 37 This is especially troubling on the System i. Scalability goes out the window if you aren’t careful!
  • 38. ASNApalooza2007ASNApalooza2007 The solution: the singleton DB patternThe solution: the singleton DB pattern • A parent class passes its job to its children, the children to their children • Results in just one job for the instance of the program 38
  • 39. ASNApalooza2007ASNApalooza2007 The bad scenarioThe bad scenario • Here both classes get their job • This effects Windows and Web programs 39
  • 40. 40 To limit the database platform one job, the parent class needs to pass its DB object around to its children (and them to their children if they have any.
  • 41. ASNApalooza2007ASNApalooza2007 There are just a few rulesThere are just a few rules • The parent, top level class, must pass its DB object on • The parent must disconnect the DB • Child can never disconnect – Others might want the job • Children can connection the DB, but should check to see if it needs to be – Others might have previously connected it 41
  • 42. ASNApalooza2007ASNApalooza2007 The singleton DB pattern is well-The singleton DB pattern is well- documenteddocumented • The downloads for Palooza (associated with this session) includes a detailed description of the singleton DB pattern • Factor it into all of your programs! • If you don’t, you are risking scalability on your database server 42
  • 43. ASNApalooza2007ASNApalooza2007 Beware shared DB connections!Beware shared DB connections! • Do not share DB connections in Web applications • This forces all users to wait on a single thread for DB connections • This is guaranteed to make you stay up late at night 43
  • 44. ASNApalooza2007ASNApalooza2007 Consider (carefully) if using threadingConsider (carefully) if using threading can help your application performancecan help your application performance • Spinning off certain processes can help application performance • One place where using threading is effective is to cause Web services to fire off a thread (to start a long-running process) and quickly return • Here is an abbreviated example…
  • 45. Spinning off the SubmitPrint process on its own thread.
  • 46. ASNApalooza2007ASNApalooza2007 In summaryIn summary • Use connection pooling. Properly! • Dispatch the KeyList where it makes sense • Use SetRange/ReadRange instead of SETLL/READE • Populate lists from read-only files • Don’t persist record locks longer than necessary 46

Editor's Notes

  1. You could argue that connection pooling isn’t directly related to file IO. We in ASNA’s tech support know better. We deal with issues nearly weekly that are reported as poor file IO and the culprit is almost always found to be improper use of connection pooling. Without effective connection pooling, your Web applications will wait several unnecessary seconds for their pages to appear.
  2. In most cases, less than 5 milliseconds.
  3. CAL = client access license where SQL Server use is licensed to a client
  4. Each time this database name is connected, it has connection enabled and has a 20 connection pooling timeout value.
  5. For a shop floor application, the operator returns to the screen infrequently during the day. If you want to pool jobs for the best performance for this type of user, you probably want something longer than 20 minutes.
  6. Let’s consider a typical Web application. It’s early in the morning, and there having been any users on the Web app for quite a while. Nothing is currently in memory for the Web app and it has no pooled System i jobs available. The jobs in the green “eggcrate” are active pooled jobs; the jobs in the red “eggcrate” are inactive pooled jobs. Let’s see how it works.
  7. This user waits 4-7 seconds for her first page.
  8. This user waits 4-7 seconds for her first page.
  9. There just barely a wait for this page for this pink (warm) user.
  10. This user waits 4-7 seconds for her first page.
  11. Given typical database connections for Web apps, the concept of the “first” user is a little interesting. In this case, it means the first of the two to request a job. In other words, the pooled job goes to asks for it first, not who used it last.
  12. The pinkt user gets her page very quickly, the
  13. While you get a job back in a matter of milliseconds, there is still other work to be done for any given page. Most pages will complete in a matter of a few hundred milliseconds, at the most.
  14. Each job expires after x minutes of inactivity from when it was last active.
  15. Something is wrong here!
  16. If you forget to close files do disconnect, the opened files are not closed for you. And. those open file handles aren’t reused across job instances. Close files, too!
  17. It’s even worse than that! Not only are you creating orphan jobs—the user is always cool and always has to wait for a new job! These orphan jobs sit unused in the active job zone until they timeout.
  18. If each user uses a unique user ID and password, each user gets her own privately pooled job.
  19. SOX refers to the Sarbanes Oxley Act which, driven by the Enron fiasco, imposes very strict accountability on public businesses.