performance engineering bob dugan, ph.d. computer science department rensselaer polytechnic...

36
Performance Performance Engineering Engineering Bob Dugan, Ph.D. Bob Dugan, Ph.D. Computer Science Department Computer Science Department Rensselaer Polytechnic Institute Rensselaer Polytechnic Institute Troy, New York 12180 Troy, New York 12180

Upload: silas-bruce

Post on 05-Jan-2016

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Performance Performance EngineeringEngineering

Bob Dugan, Ph.D.Bob Dugan, Ph.D.

Computer Science DepartmentComputer Science Department

Rensselaer Polytechnic InstituteRensselaer Polytechnic Institute

Troy, New York 12180Troy, New York 12180

Page 2: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

The Nightmare ScenarioThe Nightmare Scenario

Product pre-sold by marketing as carrier scalable

Demos are flashy, fast and successful

Product is supposed to ship to big name customers like GM, Fidelity, and AT&T a week after QA

During QA product is performance tested

Performance tests uncover serious scalability problems

Analysis shows a fundamental architecture flaw

Months of redesign and testing necessary to fix

Page 3: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

OverviewOverview

Background Methodology Resources

Incorporate performance into software’s entire life cycleto achieve performance goals.

Page 4: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

BackgroundBackground

What is software performance?

Page 5: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

BackgroundBackground

Response Time

ThroughputResource Utilization

Page 6: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Background: Response Background: Response TimeTime

How long does it take for a request to execute? Example:

Web page takes 100ms to return to browser after

request.

Interactive applications require 2000ms or less. Tells us a lot about how system is performing. Response time has big impact on the holy grail

of performance THROUGHPUT.

Page 7: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Background: ThroughputBackground: Throughput How many requests per second can be processed? Example:

A server has throughput of 30 requests/sec Supports roughly 1 million requests/10 hour day Assume average user makes 10 requests/day Server will support approximately 100,000 users

Inverse of response time on lightly loaded system. Combined with user model, can be used for performance requirements, capacity planning, sales, and marketing.

Page 8: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Background: Resource Background: Resource UtilizationUtilization

Resources consumed by code processing request. Examples: CPU, memory, network, disk In a closed system, as load increases:

Throughput rises linearly Resources are consumed Response time remains near constant

When a resource is completely consumed: Throughput remains constant Resource utilization remains near constant Response time rises linearly with load

Page 9: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Background: Resource Background: Resource UtilizationUtilization

Virtual UsersVirtual Users Response Response TimeTime

ThroughpuThroughputt

CPU CPU UtilizationUtilization

11 100ms100ms 10 req/sec10 req/sec 25%25%

22 110ms110ms 19 req/sec19 req/sec 53%53%

44 130ms130ms 38 req/sec38 req/sec 96%96%

88 300ms300ms 37 req/sec37 req/sec 98%98%

1616 640ms640ms 39 req/sec39 req/sec 99%99%

Resource utilization is critical to determining throughput/response time relationships.

During performance testing, resource utilization helps identify the cause of a performance problem.

Page 10: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Performance Performance Engineering Engineering MethodologyMethodology

Incorporate performance into software’s entire life cycle to achieve performance goals.

Page 11: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Software Life CycleSoftware Life Cycle

Requirements

Specification

Design

Implementation

Integration

Test

Release

Maintenance

Page 12: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

RequirementsRequirements

Functional requirements identified. What are the performance

requirements? Do any functional requirements

interfere with performance requirements?

Page 13: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Performance Performance RequirementsRequirements

What is the capacity planning guide for the system?

How much is a customer willing to pay for performance and scalability? Hardware Software licensing (e.g. OS, Oracle, etc.) System Administration

Page 14: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Example: Internet BankExample: Internet Bank

View accounts Search for specific transaction Transfer money between accounts Export account to Quicken 10 million potential users

Page 15: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Performance ModelPerformance Model

Make some assumptions (refine later) Three tier system: browser, web farm, database

server Database updated nightly with day’s transactions

(e.g. read mostly) User logs in once per 5 day work week, between

8AM-6PM EST Logins evenly distributed Typical user does 3 things, then logs off About 20% of customers will actually use online

banking

Page 16: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Performance ModelPerformance Model

10,000,000 users x 20% adoption rate = 2,000,000 users/week2,000,000 x 3 requests per user = 6,000,000 requests/week6,000,000 / 5 day work week = 1,200,000 requests/day1,200,000 / 10 hour day = 120,000 requests/hour120,000 / 60 minutes per hour = 2000 requests / minute2000 / 60 seconds per hour =

33 requests per second33 requests per second

Page 17: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Performance ModelPerformance Model

Page 18: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Performance Performance RequirementsRequirements

The customer wants to pay as little as possible for the system hardware.

Your company wants the system to perform well, but there’s a development cost.

YOU must find the balance. What are reasonable service times and

throughput for web and database servers?

Page 19: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Performance Performance RequirementsRequirements

DescriptionDescription TimeTime ThroughputThroughput

Web/App Service Web/App Service TimeTime

< 1000 ms< 1000 ms 1 req/sec per 1 req/sec per processorprocessor

Database Service Database Service TimeTime

< 100 ms< 100 ms 10 req/sec per 10 req/sec per processorprocessor

Total Response Total Response TimeTime

< 1100 ms< 1100 ms 33 req/sec33 req/sec

Page 20: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

RequirementsRequirements

Goal: Identify/eliminate performance problems before theyget into Functional/Design/UI specifications.

Page 21: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Functional/Design/UIFunctional/Design/UI

Goal: Eliminate performance problems before writing a line of code.Example:

Requirements say that users should be able to search on account activity using any combination of activity fields (e.g. date, payee, amount, check#).

Functional/Design specification describes an ad-hoc query mechanism with pseudocode that allows users to conduct this search using a single database query.

Performance analysis of prototype ad-hoc query shows a throughput of 2 req/sec with 100% CPU utilization on a two processor database server.

Page 22: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

PrototypingPrototyping Great time to play Investigate competing architectures Don’t forget performance!

Example: HTML Tag Processing Engine for Internet Bank Initial performance analysis showed 5 tags/sec. Web server

CPU 100%. Dependency on size of page. Second iteration improved to 20 tags/sec. Still too slow!

Service time allotted completely consumed by tag processing.

Third iteration at 60 tags/sec. No page size dependency.

Page 23: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

ImplementationImplementation

Long duration Break into drops Performance assessment of drops Track progress A maturing system increases in complexity and

jeopardizes performance Use instrumentation!

Goal: Identify and eliminate performance problems before they are discovered in QA.

Page 24: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

InstrumentationInstrumentation

Code must be instrumented by development Allows self-tuning Provides execution trace for debugging Aids performance analysis in lab Useful for monitoring application in

production

Page 25: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Example: InstrumentationExample: Instrumentation

PUNCHIN eCal::Metrics::TableStatisticsDB::unitTest []

|PUNCHIN eCal::Metrics::TableStatisticsDB::tableSelect []

||PUNCHIN eCal::Oracle::prepare []

||PUNCHOUT eCal::Oracle::prepare [] 131.973028182983 msecs

|PUNCHOUT eCal::Metrics::TableStatisticsDB::tableSelect [] 642.809987068176 msecs

PUNCHOUT eCal::Metrics::TableStatisticsDB::unitTest [] 643.355011940002 msecs

sub unitTest {

eCal::Metrics->new()->punchIn();

my $tableName;

my $result = tableSelect("users");

print $result."\n";

eCal::Metrics->new()->punchOut();

}

eCal::Metrics->new()->setEnabled("true");

eCal::Metrics->new()->setShowExecutionTrace("true");

unitTest;

Sample code

Sample instrumentation output

Activating instrumentation

Page 26: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

TestingTesting

Goal: Identify and eliminate performance problems before they get into production.

Performance testing and analysis must occur throughput development!!!

In late cycle QA, should be a formality with no surprises.

A surprise at this point will delay product release or potentially kill a product.

Page 27: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

MaintenanceMaintenance

Goal: Identify and eliminate performance problems before they are detected by users.

Management console for resource monitoring

Metrics pages Instrumentation

Page 28: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

ConclusionConclusion

Incorporate performance into software’s

entire life cycle to achieve performance goals.

Page 29: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Resources: BooksResources: Books

Smith/Williams, “Software Performance Engineering” Jain, “The Art of Computer Systems Performance Analysis” Tannenbaum, “Modern Operating Systems” Elmasri/Navathe, “Fundamentals of Database Systems” Baase, “Computer Algorithms: An Introduction to Design

and Analysis”

Page 30: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Resources: SoftwareResources: Software Resource Monitoring:

Task Manager, Perfmon Sar/iostat/netstat/stdprocess, SE Toolkit BMC Best/1, HP OpenView, Precise Insight

Load Generation LoadRunner, SilkPerformer Webload

Automated Instrumentation Numega True Time, Jprobe Tkprof, Explain Plan, Precise In Depth for Oracle

Page 31: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Resources: Literature/WebResources: Literature/Web www.perfeng.comwww.perfeng.com - Dr. Connie Smith’s Website www.spec.orgwww.spec.org - Benchmarks for computer hardware www.tpc.orgwww.tpc.org - Benchmarks for databases Computer Management Group – annual conference in

December. Workshop on Software Performance – semi-annual

conference in late summer/early fall ACM SIGMETRICs – annual conference in early summer. ACM SIGSOFT/SIGMETRICS publications – periodically

feature papers on performance engineering.

Page 32: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Case StudiesCase Studies

Page 33: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Case Study: Microsoft Case Study: Microsoft VBScriptVBScript

resp = resp & “<ul>”resp = resp & “<ul>”

I=0I=0

while (I<MAX) {while (I<MAX) {

resp = resp & “<li> List Element” & I & oneKString resp = resp & “<li> List Element” & I & oneKString

}}

resp = resp & “</ul>”resp = resp & “</ul>”

Website uses IIS, Microsoft ASP, VBScriptWebsite uses IIS, Microsoft ASP, VBScript Critical page takes 3000 ms, CPU boundCritical page takes 3000 ms, CPU bound Instrumentation shows 2500 ms in a single subroutineInstrumentation shows 2500 ms in a single subroutine Subroutine executed just before html returned to browserSubroutine executed just before html returned to browser Approximate size of HTML page is 64KApproximate size of HTML page is 64K

Page 34: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Case Study: Microsoft Case Study: Microsoft VBScriptVBScript

MAXMAX Response Response TimeTime

Average Time per Average Time per IterationIteration

1010 10ms10ms 1ms1ms

100100 800ms800ms 8ms8ms

10001000 50000ms50000ms 50ms50ms

1000010000 2,000,000m2,000,000mss

200ms200ms

The more the loop iterates, the longer each iteration takes.The more the loop iterates, the longer each iteration takes. VBScript does not support string concatenation VBScript does not support string concatenation Each string operation results in a malloc(), copy, and free which is Each string operation results in a malloc(), copy, and free which is

dependent on the current size of the html stringdependent on the current size of the html string Why is that so bad?Why is that so bad?

Page 35: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Case Study: Microsoft Case Study: Microsoft VBScriptVBScript

I = 1

n

oneK string malloc()cost of malloc() =

Sn = 1 + 2 + … + (n-1) + nSn = n + (n-1) + … + 2 + 1

2Sn = (n+1) + (n+1) + … + (n+1) +(n+1)

Sn = n(n+1)/2

Page 36: Performance Engineering Bob Dugan, Ph.D. Computer Science Department Rensselaer Polytechnic Institute Troy, New York 12180

Case Study: Microsoft Case Study: Microsoft VBScriptVBScript

SolutionSolutions?s?