SlideShare uma empresa Scribd logo
1 de 57
Baixar para ler offline
Ravi Okade
Slides from Philly.NET code camp June 2014
All architecture is
design but not all
design is
architecture.
Architecture
represents the
significant design
decisions that shape
a system, where
significant is
measured by cost of
change.
Source: wikiquote.org
Grady Booch
Intro
 We will talk about ideas to optimize your
application architecture.
 We will talk about some theory and
some practice! Hope you will like it 
Source: wikiquote.org
Donald Knuth
If you find that you're
spending almost all
your time on theory,
start turning some
attention to practical
things; it will improve
your theories.
If you find that you're
spending almost all
your time on practice,
start turning some
attention to
theoretical things; it
will improve your
practice.
Agenda: (Re)Visiting the
programming 101
 Data Structures and Algorithms
 Serialization
 Synchronization
 Other stuff (Rx, functional and so on)
Optimizing Application Architecture (.NET/Java topics)
Do you know ..
 What sorting algorithm is used by
Array.Sort ?
 Describe internals of List<T>. Compare
and contrast with LinkedList<T>
Array.Sort
Source: http://msdn.microsoft.com/en-us/library/6tf1f0bc.aspx
Quicksort honored as
one of top 10 algorithms
of 20th century
in science and
engineering.
Source: Wikipedia.org
Quicksort invented by Tony Hoare
(1960)
Why does it matter ?
Robert Sedgwick, Princeton University http://www.cs.princeton.edu/~rs/
Lists
 List<T> in .NET is highly optimized
 You typically never have to use anything
else
 Initial size makes a difference
Consider an array!
 Arrays are written using native code
 Much faster than all other data
structures
Interesting Lists - Skiplist
A Skip list is a data structure that allows fast
search within an ordered sequence of elements.
Fast search is made possible by maintaining a
linked hierarchy of subsequences, each skipping
over fewer elements
From Wikipedia - http://en.wikipedia.org/wiki/Skip_list
Skiplist - searching example
From Scott Mitchell’s article in MSDN “An Extensive Examination of Data Structures Using C# 2.0”
.NET Specialized
Collections
ListDictionary Implements IDictionary using a singly linked
list. Recommended for collections that
typically include fewer than 10 items.
HybridDictionary Implements IDictionary by using
a ListDictionary while the collection is small,
and then switching to a Hashtable when the
collection gets large.
NameValueCollection Represents a collection of
associated String keys and String values that
can be accessed either with the key or with
the index.
StringDictionary Implements a hash table with the key and the
value strongly typed to be strings rather than
objects.
Many more – see: System.Collections.Specialized Namespace
No Guarantees! Question
everything
https://www.youtube.com/watch?v=YQs6IC-vgmo#t=6
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
Serialization is a solved
problem!
 BinaryFormatter
 NetDataContractSerializer
 BinaryNetDataContractSerializer
 DataContractJsonSerializer
 XmlSerializer
 BinaryXmlSerializer
 DataContractSerializer
 BinaryDataContractSerializer
Or is it ?
Serialization matters..
 Data exchange across clear boundaries
works very well with xml/json.
 But Lot of data exchange is still internal.
Examples:
 Data Services for Thick clients
 Storing data in a cache
 Distributed computing, cloud storage
Popular protocols
 Protocol Buffer (Protobuf)
 Created 2001; Opensourced 2008
 Designed and used extensively by Google
 Apache Thrift
 Created in 2007
 Used extensively in Facebook
 Apache Avro
 Created by LinkedIn and open sourced in
2011
See a good overview of different protocols here
See performance comparison of various formats here
So many ways to serialize!
Serialization time for various protocols
https://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking
ProtoBuf.NET Size comparison
5
251
928
170 212
32
ProtoBuf.NET Time comparison
ProtoBuf.NET Performance
Serializer Size
Serialization
Time
Deserialization
Time
Protobuf-net 5 842 3,535
BinaryFormatter 251 11,618 15,178
SoapFormatter 928 47,179 79,218
XmlSerializer 170 15,373 22,216
DataContractSerializer 212 3,778 11,455
DataContractJsonSerializer 32 4,129 18,728
https://code.google.com/p/protobuf-net/wiki/Performance
ProtoBuf.NET Attributes
From ProtoBuf.Net Quickstart (Download from SVN here code). This example project is
in QuickStart folder
ProtoBuf.NET Serialization
code
Nice samples here and here
ProtoBuf schema
package QuickStart;
message Contact {
optional string Name = 1;
optional string ContactDetails = 2;
}
message Customer {
optional string CustomerId = 1;
optional string Name = 2;
optional double MaximumOrderAmount = 3;
repeated Contact Contacts = 4;
}
ProtoBuf.NET Serialization
without attributes
Protobuf Demo
 Serialize/Deserialize example in .NET
 Protobuf Schema
 Using data serialized using .NET in Java
Avro Comparison
 Dynamic typing: Avro does not require that code be
generated. Data is always accompanied by a
schema that permits full processing of that data
without code generation, static datatypes, etc.
 Untagged data: Since the schema is present when
data is read, considerably less type information need
be encoded with data, resulting in smaller
serialization size.
 Schema evolution: Avro requires schemas when
data is written or read. Most interesting is that you
can use different schemas for serialization and
deserialization, and Avro will handle the
missing/extra/modified fields.
Avro Demo
 Using Avro Schema and GenericRecord
(Both in .NET and Java)
 Comparing the output sizes of various
Codecs (Java sample)
 Serialize in Java and consume in .NET
and vice-versa.
Simplicity does
not precede
complexity, but
follows it.
Alan J. Perlis (1922 – 1990)
First recipient of the Turing Award.
Alan J. Perlis
Avoiding and Eliminating
James Reinders (Intel)
From Rules for Parallel Programming for Multicore
Reduced lock and lock-less
collections
 ConcurrentDictionary
 Immutable Collections in .NET 4.5
ConcurrentDictionary
 Available in .NET 4.0
 Needs adjustment to your code
Immutable Collections in .NET
4.5
 System.Collections.Immutable namespace
 ImmutableDictionary<TKey, TValue>
 ImmutableSortedDictionary<TKey, TValue>
 ImmutableHashSet<T>
 ImmutableList<T>
 ImmutableQueue<T>
 ImmutableSortedSet<T>
 ImmutableStack<T>
 Needs adjustment. See this
 Also immutable collections are slower.
Benchmark!
Also see this nice series of blogposts by Eric Lippert
Immutable<T> Demo
Optimizing Application Architecture (.NET/Java topics)
Preaching ..
 DRY - Don’t repeat yourself
 Abstraction Principle
 KISS (Keep it simple, stupid!)
 Avoid Creating a YAGNI (You aren’t going to need it)
 Do the simplest thing that could possibly work
 Don’t make me think
 Open/Closed Principle
 Write Code for the Maintainer
 Principle of least astonishment
 Single Responsibility Principle
 Minimize Coupling
 Maximize Cohesion
Mostly Quoted from: http://www.artima.com/weblogs/viewpost.jsp?thread=331531
More preaching
 Hide Implementation Details
 Law of Demeter
 Avoid Premature Optimization
 Code Reuse is Good
 Separation of Concerns
 Embrace Change
 Write Unit tests, know your mock
 Have good code coverage
 Use Dependency Injection
 Lint your code, cover your coverage (80%+)
 Use frequent builds/test runs
Mostly Quoted from: http://www.artima.com/weblogs/viewpost.jsp?thread=331531
"How to test?" is a
question that cannot
be answered in
general. "When to
test?" however, does
have a general
answer: as early and
as often as possible.
Bjarne Stroustrup
Optimizing Application Architecture (.NET/Java topics)
Think outside the box
 Consider Functional
 Consider Rx
 Read up on new developments in the
Big Data/High speed computing fronts:
 AKKA, Apache Spark, DataTorrent
 Disruptor pattern, Mechanical Sympathy,
Work Stealing pattern
Object-oriented
programming is an
exceptionally bad
idea which could only
have originated in
California.
Edsger Dijkstra
http://en.wikiquote.org/wiki/Talk:Edsger_W._Dijkstra
Consider Functional
 Helps you think differently
 Immutable data-structures
 No side affects
 Functions don’t care about state
 Partial evaluations (higher order
functions)
QuickSort in functional languages
Haskell (1990)
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter
(>= x) xs)
F# (2005)
let rec quicksort l =
match l with
| [] -> []
| h::t -> quicksort (List.filter (fun x -> x < h) t) @ h
:: quicksort (List.filter (fun x -> x >= h) t)
http://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort
C# is functional too! Quicksort
using Linq
public IEnumerable<T> Quicksort(List<T> v, IComparer<T> comparer) {
if (v.Count < 2)
return v;
T pivot = v[v.Count / 2];
return Quicksort(v.Where(x => comparer.Compare(x, pivot) < 0), comparer)
.Concat(new T[] { pivot })
.Concat(Quicksort(v.Where(x => comparer.Compare(x, pivot) > 0),
comparer));
}
http://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort
Consider Rx
 Great for pub-sub scenarios with
impedance mismatch:
 Async
 Event streams
 Well suited for front-end (WPF, Winforms)
 It makes your code simple and safe
 If you like Linq, you will love Rx!
 Rx is getting popular and is now available
for Java and JavaScript
Learning Rx
 MSDN has very good examples
 Excellent book by Lee Campbell (Free!)
Rx in 15 minutes
http://channel9.msdn.com/Blogs/Charles/Erik-Meijer-Rx-in-15-Minutes
Source – code sample from Oliver Lohmann MSFT
Fools ignore complexity. Pragmatists
suffer it. Some can avoid it. Geniuses
remove it.
Alan J. Perlis
</End>

Mais conteúdo relacionado

Mais procurados

Programming with Semantic Broad Data
Programming with Semantic Broad DataProgramming with Semantic Broad Data
Programming with Semantic Broad DataSteffen Staab
 
2010 03 Lodoxf Openflydata
2010 03 Lodoxf Openflydata2010 03 Lodoxf Openflydata
2010 03 Lodoxf OpenflydataJun Zhao
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity FrameworkDoncho Minkov
 
Java hibernate orm implementation tool
Java hibernate   orm implementation toolJava hibernate   orm implementation tool
Java hibernate orm implementation tooljavaease
 
(Semi-)Automatic analysis of online contents
(Semi-)Automatic analysis of online contents(Semi-)Automatic analysis of online contents
(Semi-)Automatic analysis of online contentsSteffen Staab
 
Fedora Overview
Fedora OverviewFedora Overview
Fedora Overvieweposthumus
 
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDSOverloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDSSumant Tambe
 
Data FAIRport Prototype & Demo - Presentation to Elsevier, Jul 10, 2015
Data FAIRport Prototype & Demo - Presentation to Elsevier, Jul 10, 2015Data FAIRport Prototype & Demo - Presentation to Elsevier, Jul 10, 2015
Data FAIRport Prototype & Demo - Presentation to Elsevier, Jul 10, 2015Mark Wilkinson
 
IBM Strategy for Spark
IBM Strategy for SparkIBM Strategy for Spark
IBM Strategy for SparkMark Kerzner
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best PracticesAndri Yadi
 
Introducing Entity Framework 4.0
Introducing Entity Framework 4.0Introducing Entity Framework 4.0
Introducing Entity Framework 4.0Bishoy Demian
 
Machine & Deep Learning: Practical Deployments and Best Practices for the Nex...
Machine & Deep Learning: Practical Deployments and Best Practices for the Nex...Machine & Deep Learning: Practical Deployments and Best Practices for the Nex...
Machine & Deep Learning: Practical Deployments and Best Practices for the Nex...inside-BigData.com
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldDavid McCarter
 
Entity framework
Entity frameworkEntity framework
Entity frameworkicubesystem
 
Apache Tika: 1 point Oh!
Apache Tika: 1 point Oh!Apache Tika: 1 point Oh!
Apache Tika: 1 point Oh!Chris Mattmann
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code FirstJames Johnson
 
Beyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software ArchitectureBeyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software ArchitectureJayaram Sankaranarayanan
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009nkaluva
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)David McCarter
 

Mais procurados (20)

Programming with Semantic Broad Data
Programming with Semantic Broad DataProgramming with Semantic Broad Data
Programming with Semantic Broad Data
 
2010 03 Lodoxf Openflydata
2010 03 Lodoxf Openflydata2010 03 Lodoxf Openflydata
2010 03 Lodoxf Openflydata
 
ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
 
Java hibernate orm implementation tool
Java hibernate   orm implementation toolJava hibernate   orm implementation tool
Java hibernate orm implementation tool
 
(Semi-)Automatic analysis of online contents
(Semi-)Automatic analysis of online contents(Semi-)Automatic analysis of online contents
(Semi-)Automatic analysis of online contents
 
Fedora Overview
Fedora OverviewFedora Overview
Fedora Overview
 
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDSOverloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
Overloading in Overdrive: A Generic Data-Centric Messaging Library for DDS
 
Data FAIRport Prototype & Demo - Presentation to Elsevier, Jul 10, 2015
Data FAIRport Prototype & Demo - Presentation to Elsevier, Jul 10, 2015Data FAIRport Prototype & Demo - Presentation to Elsevier, Jul 10, 2015
Data FAIRport Prototype & Demo - Presentation to Elsevier, Jul 10, 2015
 
IBM Strategy for Spark
IBM Strategy for SparkIBM Strategy for Spark
IBM Strategy for Spark
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best Practices
 
Introducing Entity Framework 4.0
Introducing Entity Framework 4.0Introducing Entity Framework 4.0
Introducing Entity Framework 4.0
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
 
Machine & Deep Learning: Practical Deployments and Best Practices for the Nex...
Machine & Deep Learning: Practical Deployments and Best Practices for the Nex...Machine & Deep Learning: Practical Deployments and Best Practices for the Nex...
Machine & Deep Learning: Practical Deployments and Best Practices for the Nex...
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real World
 
Entity framework
Entity frameworkEntity framework
Entity framework
 
Apache Tika: 1 point Oh!
Apache Tika: 1 point Oh!Apache Tika: 1 point Oh!
Apache Tika: 1 point Oh!
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
 
Beyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software ArchitectureBeyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software Architecture
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)
 

Destaque

Destaque (8)

ZeroMq ZooKeeper and FlatBuffers
ZeroMq ZooKeeper and FlatBuffersZeroMq ZooKeeper and FlatBuffers
ZeroMq ZooKeeper and FlatBuffers
 
25 Famous Websites using Wordpress
25 Famous Websites using Wordpress25 Famous Websites using Wordpress
25 Famous Websites using Wordpress
 
Dyna trace
Dyna traceDyna trace
Dyna trace
 
Java vs .Net
Java vs .NetJava vs .Net
Java vs .Net
 
Core banking
Core bankingCore banking
Core banking
 
Core banking
Core bankingCore banking
Core banking
 
A Comparison of .NET Framework vs. Java Virtual Machine
A Comparison of .NET Framework vs. Java Virtual MachineA Comparison of .NET Framework vs. Java Virtual Machine
A Comparison of .NET Framework vs. Java Virtual Machine
 
Top .NET, Java & Web Performance Mistakes - Meetup Jan 2015
Top .NET, Java & Web Performance Mistakes - Meetup Jan 2015Top .NET, Java & Web Performance Mistakes - Meetup Jan 2015
Top .NET, Java & Web Performance Mistakes - Meetup Jan 2015
 

Semelhante a Optimizing Application Architecture (.NET/Java topics)

Performance By Design
Performance By DesignPerformance By Design
Performance By DesignGuy Harrison
 
136 latest dot net interview questions
136  latest dot net interview questions136  latest dot net interview questions
136 latest dot net interview questionssandi4204
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The EnterpriseDaniel Egan
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowKaxil Naik
 
MySQL And Search At Craigslist
MySQL And Search At CraigslistMySQL And Search At Craigslist
MySQL And Search At CraigslistJeremy Zawodny
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital.AI
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020Thodoris Bais
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented developmentrajmundr
 
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...Jürgen Ambrosi
 
Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Federico Panini
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
 
Essential Data Engineering for Data Scientist
Essential Data Engineering for Data Scientist Essential Data Engineering for Data Scientist
Essential Data Engineering for Data Scientist SoftServe
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning Arno Huetter
 
Inside SQL Server In-Memory OLTP
Inside SQL Server In-Memory OLTPInside SQL Server In-Memory OLTP
Inside SQL Server In-Memory OLTPBob Ward
 
Perl and Elasticsearch
Perl and ElasticsearchPerl and Elasticsearch
Perl and ElasticsearchDean Hamstead
 
Data Engineering for Data Scientists
Data Engineering for Data Scientists Data Engineering for Data Scientists
Data Engineering for Data Scientists jlacefie
 
UnConference for Georgia Southern Computer Science March 31, 2015
UnConference for Georgia Southern Computer Science March 31, 2015UnConference for Georgia Southern Computer Science March 31, 2015
UnConference for Georgia Southern Computer Science March 31, 2015Christopher Curtin
 

Semelhante a Optimizing Application Architecture (.NET/Java topics) (20)

Modern C++
Modern C++Modern C++
Modern C++
 
Performance By Design
Performance By DesignPerformance By Design
Performance By Design
 
136 latest dot net interview questions
136  latest dot net interview questions136  latest dot net interview questions
136 latest dot net interview questions
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
MySQL And Search At Craigslist
MySQL And Search At CraigslistMySQL And Search At Craigslist
MySQL And Search At Craigslist
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented development
 
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
 
Devoxx
DevoxxDevoxx
Devoxx
 
Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)Elasticsearch quick Intro (English)
Elasticsearch quick Intro (English)
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Essential Data Engineering for Data Scientist
Essential Data Engineering for Data Scientist Essential Data Engineering for Data Scientist
Essential Data Engineering for Data Scientist
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
 
Inside SQL Server In-Memory OLTP
Inside SQL Server In-Memory OLTPInside SQL Server In-Memory OLTP
Inside SQL Server In-Memory OLTP
 
Perl and Elasticsearch
Perl and ElasticsearchPerl and Elasticsearch
Perl and Elasticsearch
 
Data Engineering for Data Scientists
Data Engineering for Data Scientists Data Engineering for Data Scientists
Data Engineering for Data Scientists
 
UnConference for Georgia Southern Computer Science March 31, 2015
UnConference for Georgia Southern Computer Science March 31, 2015UnConference for Georgia Southern Computer Science March 31, 2015
UnConference for Georgia Southern Computer Science March 31, 2015
 

Mais de Ravi Okade

Preparing for AWS certified solutions architect associate exam (saa-c02)
Preparing for AWS certified solutions architect associate exam (saa-c02)Preparing for AWS certified solutions architect associate exam (saa-c02)
Preparing for AWS certified solutions architect associate exam (saa-c02)Ravi Okade
 
Azure blockchain service
Azure blockchain serviceAzure blockchain service
Azure blockchain serviceRavi Okade
 
Are you writing acceptance test yet?
Are you writing acceptance test yet?Are you writing acceptance test yet?
Are you writing acceptance test yet?Ravi Okade
 
License plate detection using cloud api's
License plate detection using cloud api'sLicense plate detection using cloud api's
License plate detection using cloud api'sRavi Okade
 
The twelve factor app
The twelve factor appThe twelve factor app
The twelve factor appRavi Okade
 
Sql Server 2014 In Memory
Sql Server 2014 In MemorySql Server 2014 In Memory
Sql Server 2014 In MemoryRavi Okade
 
Dot Net Application Monitoring
Dot Net Application MonitoringDot Net Application Monitoring
Dot Net Application MonitoringRavi Okade
 

Mais de Ravi Okade (7)

Preparing for AWS certified solutions architect associate exam (saa-c02)
Preparing for AWS certified solutions architect associate exam (saa-c02)Preparing for AWS certified solutions architect associate exam (saa-c02)
Preparing for AWS certified solutions architect associate exam (saa-c02)
 
Azure blockchain service
Azure blockchain serviceAzure blockchain service
Azure blockchain service
 
Are you writing acceptance test yet?
Are you writing acceptance test yet?Are you writing acceptance test yet?
Are you writing acceptance test yet?
 
License plate detection using cloud api's
License plate detection using cloud api'sLicense plate detection using cloud api's
License plate detection using cloud api's
 
The twelve factor app
The twelve factor appThe twelve factor app
The twelve factor app
 
Sql Server 2014 In Memory
Sql Server 2014 In MemorySql Server 2014 In Memory
Sql Server 2014 In Memory
 
Dot Net Application Monitoring
Dot Net Application MonitoringDot Net Application Monitoring
Dot Net Application Monitoring
 

Último

UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 

Último (20)

UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 

Optimizing Application Architecture (.NET/Java topics)

  • 1. Ravi Okade Slides from Philly.NET code camp June 2014
  • 2. All architecture is design but not all design is architecture. Architecture represents the significant design decisions that shape a system, where significant is measured by cost of change. Source: wikiquote.org Grady Booch
  • 3. Intro  We will talk about ideas to optimize your application architecture.  We will talk about some theory and some practice! Hope you will like it 
  • 4. Source: wikiquote.org Donald Knuth If you find that you're spending almost all your time on theory, start turning some attention to practical things; it will improve your theories. If you find that you're spending almost all your time on practice, start turning some attention to theoretical things; it will improve your practice.
  • 5. Agenda: (Re)Visiting the programming 101  Data Structures and Algorithms  Serialization  Synchronization  Other stuff (Rx, functional and so on)
  • 7. Do you know ..  What sorting algorithm is used by Array.Sort ?  Describe internals of List<T>. Compare and contrast with LinkedList<T>
  • 9. Quicksort honored as one of top 10 algorithms of 20th century in science and engineering. Source: Wikipedia.org Quicksort invented by Tony Hoare (1960)
  • 10. Why does it matter ? Robert Sedgwick, Princeton University http://www.cs.princeton.edu/~rs/
  • 11. Lists  List<T> in .NET is highly optimized  You typically never have to use anything else  Initial size makes a difference
  • 12. Consider an array!  Arrays are written using native code  Much faster than all other data structures
  • 13. Interesting Lists - Skiplist A Skip list is a data structure that allows fast search within an ordered sequence of elements. Fast search is made possible by maintaining a linked hierarchy of subsequences, each skipping over fewer elements From Wikipedia - http://en.wikipedia.org/wiki/Skip_list
  • 14. Skiplist - searching example From Scott Mitchell’s article in MSDN “An Extensive Examination of Data Structures Using C# 2.0”
  • 15. .NET Specialized Collections ListDictionary Implements IDictionary using a singly linked list. Recommended for collections that typically include fewer than 10 items. HybridDictionary Implements IDictionary by using a ListDictionary while the collection is small, and then switching to a Hashtable when the collection gets large. NameValueCollection Represents a collection of associated String keys and String values that can be accessed either with the key or with the index. StringDictionary Implements a hash table with the key and the value strongly typed to be strings rather than objects. Many more – see: System.Collections.Specialized Namespace
  • 20. Serialization is a solved problem!  BinaryFormatter  NetDataContractSerializer  BinaryNetDataContractSerializer  DataContractJsonSerializer  XmlSerializer  BinaryXmlSerializer  DataContractSerializer  BinaryDataContractSerializer
  • 21. Or is it ?
  • 22. Serialization matters..  Data exchange across clear boundaries works very well with xml/json.  But Lot of data exchange is still internal. Examples:  Data Services for Thick clients  Storing data in a cache  Distributed computing, cloud storage
  • 23. Popular protocols  Protocol Buffer (Protobuf)  Created 2001; Opensourced 2008  Designed and used extensively by Google  Apache Thrift  Created in 2007  Used extensively in Facebook  Apache Avro  Created by LinkedIn and open sourced in 2011 See a good overview of different protocols here See performance comparison of various formats here
  • 24. So many ways to serialize! Serialization time for various protocols https://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking
  • 27. ProtoBuf.NET Performance Serializer Size Serialization Time Deserialization Time Protobuf-net 5 842 3,535 BinaryFormatter 251 11,618 15,178 SoapFormatter 928 47,179 79,218 XmlSerializer 170 15,373 22,216 DataContractSerializer 212 3,778 11,455 DataContractJsonSerializer 32 4,129 18,728 https://code.google.com/p/protobuf-net/wiki/Performance
  • 28. ProtoBuf.NET Attributes From ProtoBuf.Net Quickstart (Download from SVN here code). This example project is in QuickStart folder
  • 30. ProtoBuf schema package QuickStart; message Contact { optional string Name = 1; optional string ContactDetails = 2; } message Customer { optional string CustomerId = 1; optional string Name = 2; optional double MaximumOrderAmount = 3; repeated Contact Contacts = 4; }
  • 32. Protobuf Demo  Serialize/Deserialize example in .NET  Protobuf Schema  Using data serialized using .NET in Java
  • 33. Avro Comparison  Dynamic typing: Avro does not require that code be generated. Data is always accompanied by a schema that permits full processing of that data without code generation, static datatypes, etc.  Untagged data: Since the schema is present when data is read, considerably less type information need be encoded with data, resulting in smaller serialization size.  Schema evolution: Avro requires schemas when data is written or read. Most interesting is that you can use different schemas for serialization and deserialization, and Avro will handle the missing/extra/modified fields.
  • 34. Avro Demo  Using Avro Schema and GenericRecord (Both in .NET and Java)  Comparing the output sizes of various Codecs (Java sample)  Serialize in Java and consume in .NET and vice-versa.
  • 35. Simplicity does not precede complexity, but follows it. Alan J. Perlis (1922 – 1990) First recipient of the Turing Award.
  • 38. James Reinders (Intel) From Rules for Parallel Programming for Multicore
  • 39. Reduced lock and lock-less collections  ConcurrentDictionary  Immutable Collections in .NET 4.5
  • 40. ConcurrentDictionary  Available in .NET 4.0  Needs adjustment to your code
  • 41. Immutable Collections in .NET 4.5  System.Collections.Immutable namespace  ImmutableDictionary<TKey, TValue>  ImmutableSortedDictionary<TKey, TValue>  ImmutableHashSet<T>  ImmutableList<T>  ImmutableQueue<T>  ImmutableSortedSet<T>  ImmutableStack<T>  Needs adjustment. See this  Also immutable collections are slower. Benchmark! Also see this nice series of blogposts by Eric Lippert
  • 44. Preaching ..  DRY - Don’t repeat yourself  Abstraction Principle  KISS (Keep it simple, stupid!)  Avoid Creating a YAGNI (You aren’t going to need it)  Do the simplest thing that could possibly work  Don’t make me think  Open/Closed Principle  Write Code for the Maintainer  Principle of least astonishment  Single Responsibility Principle  Minimize Coupling  Maximize Cohesion Mostly Quoted from: http://www.artima.com/weblogs/viewpost.jsp?thread=331531
  • 45. More preaching  Hide Implementation Details  Law of Demeter  Avoid Premature Optimization  Code Reuse is Good  Separation of Concerns  Embrace Change  Write Unit tests, know your mock  Have good code coverage  Use Dependency Injection  Lint your code, cover your coverage (80%+)  Use frequent builds/test runs Mostly Quoted from: http://www.artima.com/weblogs/viewpost.jsp?thread=331531
  • 46. "How to test?" is a question that cannot be answered in general. "When to test?" however, does have a general answer: as early and as often as possible. Bjarne Stroustrup
  • 48. Think outside the box  Consider Functional  Consider Rx  Read up on new developments in the Big Data/High speed computing fronts:  AKKA, Apache Spark, DataTorrent  Disruptor pattern, Mechanical Sympathy, Work Stealing pattern
  • 49. Object-oriented programming is an exceptionally bad idea which could only have originated in California. Edsger Dijkstra http://en.wikiquote.org/wiki/Talk:Edsger_W._Dijkstra
  • 50. Consider Functional  Helps you think differently  Immutable data-structures  No side affects  Functions don’t care about state  Partial evaluations (higher order functions)
  • 51. QuickSort in functional languages Haskell (1990) qsort [] = [] qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs) F# (2005) let rec quicksort l = match l with | [] -> [] | h::t -> quicksort (List.filter (fun x -> x < h) t) @ h :: quicksort (List.filter (fun x -> x >= h) t) http://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort
  • 52. C# is functional too! Quicksort using Linq public IEnumerable<T> Quicksort(List<T> v, IComparer<T> comparer) { if (v.Count < 2) return v; T pivot = v[v.Count / 2]; return Quicksort(v.Where(x => comparer.Compare(x, pivot) < 0), comparer) .Concat(new T[] { pivot }) .Concat(Quicksort(v.Where(x => comparer.Compare(x, pivot) > 0), comparer)); } http://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort
  • 53. Consider Rx  Great for pub-sub scenarios with impedance mismatch:  Async  Event streams  Well suited for front-end (WPF, Winforms)  It makes your code simple and safe  If you like Linq, you will love Rx!  Rx is getting popular and is now available for Java and JavaScript
  • 54. Learning Rx  MSDN has very good examples  Excellent book by Lee Campbell (Free!)
  • 55. Rx in 15 minutes http://channel9.msdn.com/Blogs/Charles/Erik-Meijer-Rx-in-15-Minutes
  • 56. Source – code sample from Oliver Lohmann MSFT
  • 57. Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it. Alan J. Perlis </End>