16
MULTITHREADING AND SCALING: Diary of a Madman #0000 TSIMAFEI AVILIN FEBRUARY 26, 2017 Maslenitsa Co.

MULTITHREADING AND SCALING: Diary of a Madman #0000

Embed Size (px)

Citation preview

Page 1: MULTITHREADING AND SCALING: Diary of a Madman #0000

MULTITHREADING AND SCALING: Diary of a Madman #0000

TSIMAFEI AVILIN

FEBRUARY 26, 2017Maslenitsa Co.

Page 2: MULTITHREADING AND SCALING: Diary of a Madman #0000

FEBRUARY 26, 2017

API TESTING+ PRE-LOAD TESTING + AZURE

MULTITHREADING AND SCALING: Diary of a Madman #0000

Page 3: MULTITHREADING AND SCALING: Diary of a Madman #0000

3CONFIDENTIAL

AGENDA

What we want to share:• PROBLEM STATEMENT• MULTI THREADING AS A PRE-LOAD TESTING• SCALING IN AZURE

Page 4: MULTITHREADING AND SCALING: Diary of a Madman #0000

4CONFIDENTIAL

PROBLEM STATEMENT

Maslenitsa is being celebrated today and you have to bake 1000 pancakes in a short time, how you gonna do that?

Page 5: MULTITHREADING AND SCALING: Diary of a Madman #0000

5CONFIDENTIAL

STEP BY STEP SOLUTIONS

bake 1000 pancakes for one cook – tooooo long!

bake 1000 pancakes for a group of cooks – much better!

+ Good approach!

Page 6: MULTITHREADING AND SCALING: Diary of a Madman #0000

6CONFIDENTIAL

PROBLEM STATEMENT

Imagine that you need to perform comparison of many thousands of items in most cases of the same type (files, DB data, strings, etc. )

Page 7: MULTITHREADING AND SCALING: Diary of a Madman #0000

7CONFIDENTIAL

OUR ARCHITECTURE \ TASK

Need to compare thousands of .xml files in a short time…Responses are coming from REST and SOAP services

Files

to b

e co

mpa

red

in S

OAP

and

REST

serv

ices

Page 8: MULTITHREADING AND SCALING: Diary of a Madman #0000

8CONFIDENTIAL

ONE THREAD, LAPTOP, 1000 files

Example of a simple method to compare API responses from REST and SOAP services

var comparisionResult = Comparison.Run(validatedUBFContext.FromSOAP, validatedUBFContext.FromREST);

Laptop processor:• Processor: Intel® Core™ i5-6300U• # Cores: 2• # Threads : 4Time to process 1000 files (each file is about 50-100Kb size of): • 31.30min

Page 9: MULTITHREADING AND SCALING: Diary of a Madman #0000

9CONFIDENTIAL

MUTLITHREADING, SAME LAPTOP, 1000 files

MaxDegreeOfParallelism – number of threadsvar opt = new ParallelOptions { MaxDegreeOfParallelism = int.Parse(ConfigurationManager.AppSettings["DegreeOfParallelization"]) };

Parallel.ForEach(validatedUBFProvider.GetUBFs(ubfStoragePath, opt, validatedUBFContext => {try {var comparisionResult = Comparison.Run(validatedUBFContext.SOAP, validatedUBFContext.REST); } }

DegreeTime, min

1 31.344 10.055 8.497 8.198 7.249 6.53

10 6.4430 650 6.2270 6.56

100 6.35150 6.14200 7

0 20 40 60 80 100 12005

101520253035

Time/Degree

Time to process 1000 files is about 6.30 min instead of 31.30min

Page 10: MULTITHREADING AND SCALING: Diary of a Madman #0000

10CONFIDENTIAL

MULTITHREADING AS PRE-LOAD TESTING

Even performing this simple testing based on multithreading and sending API requests (.xml files ~ 60.000 files per day ) to both REST and SOAP services, brought out some issues:

• DB issues (DB architecture, indexing, procedures, etc.)• API issues (500 internal server error as internal api issues, scaling, etc.)• APP CONFIGURATION issues (no specific configuration file, code regression

issues, needs of additional system specific activities like restart IIS which is an issue, etc.)

• Indicating of a maximum request size as a system confines• Caching issues• etc.

Page 11: MULTITHREADING AND SCALING: Diary of a Madman #0000

11CONFIDENTIAL

FEBRUARY 26, 2017

GO FORWARD AND USE AZURE PRICES PLANS

Page 12: MULTITHREADING AND SCALING: Diary of a Madman #0000

12CONFIDENTIAL

SCALING IN AZURE : DB (DTU)Database Throughput Unit (DTU): DTUs provide a way to describe the relative capacity of a performance level. DTUs are based on a blended measure of CPU, memory, reads, and writes. As DTUs increase, the power offered by the performance level increases.

Page 13: MULTITHREADING AND SCALING: Diary of a Madman #0000

13CONFIDENTIAL

SCALING IN AZURE : APP SERVICE

Page 14: MULTITHREADING AND SCALING: Diary of a Madman #0000

14CONFIDENTIAL

MUTLITHREADING, SAME LAPTOP, 1000 files, scaling in Azure

Because of files to be validated\verifying are processed on VM in Azure (DB + SOAP) on the one hand and REST service on another one, we can try to play with pricing plans to make better performance of DB and a instance where service is running.

DTU S2 S0 S0 S0 S1 S3 P1 P2 P2

APP SERVICE S2 S2 S1 S3 S2 S2 S2 S2 P3

Number of threads:10/ min 6.14 6.59 6.49 7.08 6.56 7.01 7.06 6.5 6.57

As it can be seen from the table above, it does not make sense to pay much money for the more expensive prices plans.It’s obvious, because laptop cannot send more requests then the processor allows based on proposed architecture and ‘infrastructure’.

Page 15: MULTITHREADING AND SCALING: Diary of a Madman #0000

15CONFIDENTIAL

MUTLITHREADING, SERVER, 1000 files, scaling in Azure

Server processor:• Processor: Intel(R) Xeon(R) CPU E5-2670 0 2.60GHz • # Cores: 8• # Threads : 16Time to process 1000 files (each file is about 50-100Kb size of) with 100 threads: • 4.30min

Threads DTUAPP SERVICEstart end dif

100P2 S3 2:49:54 2:54:36 0:04:42100P1 S3 3:06:25 3:10:49 0:04:24100S3 S3 3:24:00 3:28:37 0:04:37100S0 S3 3:58:50 4:04:34 0:05:44100P2 S1 5:07:30 5:12:27 0:04:57

Scaling in Azure:

S0\S3 vs S3\S3- the difference is only ~1 min, but in case of 20K files it would be about 20min

Page 16: MULTITHREADING AND SCALING: Diary of a Madman #0000

16CONFIDENTIAL

FEBRUARY 26, 2017

THANKS! ДЗЯКУЮ! СПАСИБО!