42
Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой нагрузкой с помощью Visual Studio 2012 Евгений Чигиринский Microsoft Corp.

Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

  • Upload
    sqalab

  • View
    236

  • Download
    1

Embed Size (px)

DESCRIPTION

Доклад Евгения Чигиринского, SQA Days-13, 26-27 апреля 2013, www.sqadays.com

Citation preview

Page 1: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

нагрузкой с помощью Visual Studio 2012

Евгений Чигиринский Microsoft Corp.

Page 2: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Содержание• Методологии тестирования

качества и нагрузки– пробы и ошибки

• От методологии – к практике на примере msn.com– Visual Studio Profiler– Тестирование нагрузки в условиях

автоматического управления датацентрами– Тестирование быстродействия на

клиентской части

Page 3: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Why MSN?

• 19 лет online• Траффик главной страницы (www.msn.com) – больше чем 4.3

миллиарда просмотров за месяц• Постоянно в Top 20 сайтов мира• Очень высокие требования к производительности сайта• Присутствует во многих странах мира

– Порталы (www.msn.ru)– Тематические сайты (http://cars.uk.msn.com/)

Page 5: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

• What does High Quality mean?• Resilience Quality• Environment Quality• Diagnostics & Monitoring Quality• Configurability• Maintainability

Page 6: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

What does High Quality mean?

Quality is not just working Functionality

Contributors to High Quality

Page 7: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Service Resilience QualityFault Tolerance

Recover from Fault conditionsDegrade GracefullyHow to Test? – Fault Injection!“Chaos Monkey”

Handling Human ErrorsConfiguration ManagementFile & backup Management

Performance thresholdsIf you don’t play well, we don’t play with you!Throttling Capabilities

Dependency mappingAvoids potential failuresReduces Mitigation TimeBetter Prediction of ImpactsLowers Maintenance Risk and Increases Efficiency

“Design for failure and nothing will fail!”

“The best way to avoid failure is to fail constantly”

Software should protect humans from making mistakes

Page 8: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Environment Quality

• Test Environments in-sync with Production Environment• Design For Roll back

• Solid Deployment testing in place• Test Rollback mechanisms thoroughly

• Design for Human Error• Quality Gates and Checks in place to prevent Corruption of Environment• Configuration Changes should be treated like full fledged deployments

• Operational Excellence• Mandatory Peer Reviews for Configuration changes & Script Executions

Page 9: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Diagnostics & Monitoring Quality

• Monitoring Being Proactive Vs. Reactive Lower MTTD [Mean Time to Detect] Lower Downtime & Higher Availability Add Monitoring Capability when you are building the service - not after! Monitoring Testing should be part of Test plan Plan for Multiple levels of Monitoring – Watch dogs, FTIP, etc

• Diagnostics• Ability to collect required data• More effective debugging and troubleshooting• Lower time to restore• How soon can we get the service back up and running

Page 10: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Maintainability

• The ease with which the system can be:• Modified to meet new requirements• Modified to make future maintenance easier• Modified to correct defects• Adapted to a changed environment

• Maintainability testing:• Maintainability Index • Cyclomatic Complexity• Class Inheritance• Class Coupling• Lines of Code

Page 11: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Methodology

• Min InstallComponent Level Testing

• Cluster Level Testing

Page 12: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Methodology : Minimal Installation

• One Box Setup• Build the baseline (expectations)• Tuning for scenarios• See what comes from experiment (run)

Page 13: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Min Install - Performance Load and Stress Testing

• Identify Production Scenarios (BVTs)– Confirm meeting original expectations– Define Baselines

• Identify Max Throughput– Identify Bottlenecks (always start one to many)– Identify Ceiling (how much work you can do with the system – can be memory, IO, CPU)– Identify Capacity– How it behaves beyond the limit

• Failure Scenarios (stress testing)– Finding failure conditions, pushing the app to failure scenarios– Examples:

• Too much traffic• Too much memory/cache items• Too many connections (resource starvation)• Network IO/Disk IO

– Failing gracefully

• Endurance Testing– Issues/Concerns happening over time (usually over 72 hours) – Leaks, Disk space, Timed events

Page 14: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Methodology : Cluster Level Testing

• Integration Testing• Prod simulation (IIS Playback, SQL playback, etc)• Testing new behavior for new features• Failing gracefully

• Load Test In Production (LTIP)

Page 15: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Performance is important

• How to improve it?– Measure– Fix– Measure again

• How to measure it with VS?– VS Profiler

Page 16: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

What is VS Profiler?

• Performance measurement tool• Process oriented

Ultimate Premium Professional Express

Page 17: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Common Performance Issue

• High CPU utilization• I/O bottleneck• Tiers interaction• Resource contention, Poor core utilization• Memory issues

Page 18: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

High CPU utilization

• Sampling: statistical form of CPU profiling• Choose Sampling when

– CPU is the critical resource– Low overhead is required

• Non-intrusive• Samples != Time

Page 19: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Sampling Profiling

• void Alpha()• {

• Beta();• }• void Beta()• {

• }

30 samples

50 samples

Exclusive Inclusive

Alpha

Beta 50 50

30 80

Page 20: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Sampling Profiling Call Tree

Page 21: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Q&A

Page 22: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

I/O bottleneck

• Instrumentation: method timing profiling• Choose Instrumentation when

– CPU usage is low– Exact function call counts are necessary– Exact timing is necessary

• Higher overhead• Intrusive

Page 23: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Instrumentation Profiling

• void MyFunction()• {• FUNC_ENTER(MyFunction);• . . .• CALL_ENTER(WriteFile);• // Call another function• WriteFile(...);• CALL_EXIT(WriteFile);• . . .• FUNC_EXIT(MyFunction);• }

Elapsed Time

ApplicationTime

ApplicationTime

Page 24: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Instrumentation Profiling Call Tree

Page 25: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Managed memory profiling

• Allocation data– Allocated type– Allocating call stack

• Lifetime data– GC generations

Page 26: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

More power to VS Profiler

• Data collection– Remote profiling– ETW based collection– Various performance counters– Command line tools– APIs

Multiproc collection Standalone profiler Collect what you need

Attach/Detach, Pause/Resume

Page 27: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

VS Profiler - Limitations

• Move to ETW in Visual Studio 2012

• Windows 8 Limitations with CPU sampling

– Tier Interaction Profiling data cannot be collected– The “Sampling” performance session cannot be configured– Windows performance counters cannot be collected while CPU sampling– NGEN-ed methods will not show real method names

Page 28: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Тестирование нагрузки в условиях автоматического управления датацентрами

Page 29: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Automatic DC Management

• Like a cloud, but with more control• Testing the deployment process• Monitoring

Page 30: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Monitoring

• Deployment monitoring– Automated rollbacks

• Watchdogs– Simple Watchdogs (disk space, CPU, etc)– User Watchdogs

• service that monitors the production service– Set machine properties with centralized service

• Alerts– Actions based on machine properties set by watchdog

Page 31: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Тестирование быстродействия на клиентской части

Page 32: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Что будет рассмотрено

TTI

PLT

TTV

PLT2

TTG

TTLB

TTO

TTFR

TTFB

VRTA

MSN PIE

Keynote

YSlow

WebPageTest

Gomez

WebRunner

Что это за метрики?

Как измерять производительность?

Что можно сделать?

Page 33: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Метрики для оценки производительности

Запросстраницы

Сервер посылаетHTML браузеру

Браузер парсирует HTML, загружает JS и CSS, строит DOM,запрашиваетизображения.

Отображениепервого видимогоэлемента

Отображениевидимой страницы

Загрузка последнеговидимого элементастраницы(чаще всего за экраном)

Вся ресурсыстраницызагружены.Browser fireson-load event

Beacons are fired

Приемпоследнегобайтастраницы.

Производительность «сервера»

TTLBTime to last byte

TTFBTime to first byte

TTFRTime to

first render

TTVTime to

last visual

TTOTime to OnLoad

TAFRAbove fold

render

Page Load Time - PLT

perceived approximated

Page 34: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Какие метрики производительности нужно использовать?

TTLBTime to last byte

TTFBTime to first byte

TTFRTime to

first render

TTVTime to

last visual

TTOTime to OnLoad

TAFRAbove fold

render

Perceived Approximated

X

Page 35: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Performance Optimizations

• Images loaded optimally in phases• Async script loading• JS execution in multiple phases• Testing on real mobile devices• Optimized ad loading• Other optimizations

Page 36: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Optimal Image Loading

Define and maintain Performance budget– PLT goal permits only 400KB weight at 100% bandwidth efficiency (less in

practice)

Responsive design– Need to load different images based on view mode (e.g. Snap view);

determined client-side– Load images in phases

Page 37: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

CPU Analysis Methodology

• Capture event traces (ETW) on the device• Use XPerf trace analysis tool to visualize CPU cost across IE subsystems

– JavaScript, CSS, Formatting, Layout, Display etc.

• Identify bottlenecks and JS code paths responsible for them

Page 38: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Example: Jerky TOC Snapping

Situation• TOC snapping animation is jerky (12fps on Surface RT)

Opportunity• Cycle of measuring and updating CSS position of TOC as user

scrolls down results in costly recalculation of entire layout tree with every loop iteration

• 80ms CPU time for each cycle results in jerky animation

Page 39: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Goal: Ads do not block Onload• Onload has impact on perceived performance, such as the ‘Done’ indicator• Onload is used to trigger secondary functionality

Example: Optimized Ad Load

Onload Ad request blocks Onload

Solution: • Modify ads handling code to avoid blocking of Onload

Onload Ad request does not block Onload

Page 40: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Key Findings for MSN

• Define and maintain perf budgets• Test as near to Prod as possible• Know your dependencies

– Avoid 3rd party libraries that are not designed with performance in mind

• Make sure that your sample data is valid• Monitoring is the key• Visual Studio Profiler helps finding issues quickly!

Page 41: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

References

• Visual Studio ALM + Team Foundation Server Bloghttp://blogs.msdn.com/b/visualstudioalm/

• Profiling Windows 8 and Windows Server 2012 applicationshttp://msdn.microsoft.com/en-us/library/hh974575.aspx

• Configuring the profiler as part of your load testing in Visual Studiohttp://msdn.microsoft.com/en-us/library/dd504817.aspx

• Load Testing in Visual Studio 2012http://blogs.msdn.com/b/visualstudioalm/archive/2012/06/04/getting-started-with-load-testing-in-visual-studio-2012.aspx

• VS Profiler – CPU Samplinghttp://blogs.msdn.com/b/visualstudioalm/archive/2013/02/27/how-to-profile-a-xaml-windows-store-app.aspx

• Profiling .NET Memory Allocationhttp://blogs.msdn.com/b/dotnet/archive/2013/04/04/net-memory-allocation-profiling-with-visual-studio-2012.aspx

Page 42: Методология и практический опыт тестирования быстродействия приложений, сервисов и сайтов с высокой

Q&A