25
Building Scalable .NET Applications Guy Nirpaz, EVP R&D, GigaSpaces Technologies

Building Scalable .NET Applications

  • Upload
    mikaia

  • View
    28

  • Download
    0

Embed Size (px)

DESCRIPTION

Building Scalable .NET Applications. Guy Nirpaz, EVP R&D, GigaSpaces Technologies. Who am I?. 3 Years with GigaSpaces VP of R&D Speaker at dev conferences: Agile, Technology, Architecture Veteran of several Startups Spent most of my life in design and architecture of complex systems - PowerPoint PPT Presentation

Citation preview

Page 1: Building Scalable .NET Applications

Building Scalable .NET Applications

Guy Nirpaz,

EVP R&D, GigaSpaces Technologies

Page 2: Building Scalable .NET Applications

Who am I?

• 3 Years with GigaSpaces– VP of R&D

– Speaker at dev conferences:

• Agile, Technology, Architecture

• Veteran of several Startups

• Spent most of my life in design and architecture of complex systems

– Financial Services, Command and Control, Teleco

– Mercury, IBM, others

• Contact:– [email protected]

– @gnirpaz – Twitter

– jroller.com/gnirpaz - Blog

Page 3: Building Scalable .NET Applications

About GigaSpaces

• A Scale-Out Platform, optimized for distributed and virtualized environments:

– Any deployment environments: clouds, grids, commodity servers, multi-core

– Any languages: Spring/Java, .Net, C++, Dynamic

• Driven by the need for:– confidence to handle unpredictable demand and peak loads;

– guaranteed performance under any processing loads;

– cost-effective, on-demand scalability for clouds and grids – rapidly develop, change and scale applications

Page 4: Building Scalable .NET Applications

Explore technical and business challenges of building scalable

applications. Analyze fundamental architecture limitations and propose

cost-effective alternative

Page 5: Building Scalable .NET Applications

Your Application

The typical scenario…

Michael Jackson Tickets are on Sale!

Page 6: Building Scalable .NET Applications

Linear Dynamic Scalability

Solution: Linear and Dynamic Scalability

Page 7: Building Scalable .NET Applications

Business tier

Back-upBack-up

Back-up

Load Balancer

Web Tier

Messaging

• Relies on centralized resources• Hard to install:

• Bound to static resources (IPs, disk drives, etc.)

• Separate clustering model for each tier• Hard to maintain• Non-scalable

Traditional Tier Based Architecture is not scalable

Page 8: Building Scalable .NET Applications

Peak loads are unpredictable

• Constant transaction, data and user growth

• Volatile and unpredictable loads

0

100,000,000

200,000,000

300,000,000

400,000,000

500,000,000

600,000,000

700,000,000

800,000,000

900,000,000

1,000,000,000

1,100,000,000

1,200,000,000

1,300,000,000

J-04 M-04 M-04 J-04 S-04 N-04 J-05 M-05 M-05 J-05 S-05 N-05 J-06 M-06 M-06 J-06 S-06 N-06 J-07 M-07 M-07 J-07 S-07

Page 9: Building Scalable .NET Applications

Scalability Disasters Are More Common Than Ever

• Lost customers• Lost revenues• Brand damage

Page 10: Building Scalable .NET Applications

Users Load Balancer

Micro-Blogging (ala Twitter) Example

IIS

Data Base

Application

Publish Service

Read Service

IIS

Application

Publish Service

Read Service

Page 11: Building Scalable .NET Applications

Reader/Publisher Service

namespace MicroBlog.Services{ public interface IReaderService {

ICollection<Post> GetUserPosts(String userID);

ICollection<Post> GetUserPosts(String userID, DateTime fromDate); }}

namespace MicroBlog.Services{ public interface IPublisherService {

void PublishPost(Post post); }}

Page 12: Building Scalable .NET Applications

Users

Load Balancer

What happens on success

IIS

Data Base

Application

Publish Service

Read Service

IIS

Application

Publish Service

Read Service

IIS

IIS

IIS

IIS

Application

Publish Service

Read Service

Application

Publish Service

Read Service

The database becomes the bottleneck

Page 13: Building Scalable .NET Applications

Reader – Database Implementation

public ICollection<Post> GetUserPosts(string userID, DateTime fromDate) {

// Create command:IDbCommand dbCommand =

_dbConnection.CreateCommand();dbCommand.CommandText = String.Format(

"SELECT * FROM Post WHERE UserID='{0}' AND PostedOn > {1}",userID, fromDate);

// Execute command:IDataReader dataReader = dbCommand.ExecuteReader();

// Translate results from db records to .NET objects:List<Post> result = ReadPostsFromDataReader(dataReader);

// Return results:return result;

}

Page 14: Building Scalable .NET Applications

Users Load Balancer

Step I – Remove DB Bottlenecks with Caching

IIS Data Base

Application

Publish Service

Read Service

Cache Service

• Reduce I/O bottlenecks – less DB access

• In-Memory caching• Reduced Network hops (if in-

process)• Suitable for read-mostly apps

Page 15: Building Scalable .NET Applications

Reader – Space Implementation

public ICollection<Post> GetUserPosts(String userID){

// Create a template to get all posts by a user id:Post template = new Post();template.UserID = userID;

// Use space proxy to read entries matching template:Post[] result = _spaceProxy.ReadMultiple(template);

// Return result:return result;

}

Page 16: Building Scalable .NET Applications

Users Load Balancer

Step II – Linear Scalability: Partitioning and Collocation

IIS Data Base

Writer

ReaderSpace

Writer

ReaderSpace

Writer

ReaderSpace

Writer

ReaderSpace

Writer

ReaderSpace

IIS

IIS

IIS

Page 17: Building Scalable .NET Applications

PosterLoad

Balancer

Post Life Cycle

WriterReader

SpaceIIS

Writer Client

ReaderClient

Post.NEW

Post.VALID

Reader

Page 18: Building Scalable .NET Applications

Writer Client

public class SpacePublisherService : IPublisherService{ private readonly ISpaceProxy _spaceProxy;

public void PublishPost(Post post) {

this._spaceProxy.Write(post); }}

Page 19: Building Scalable .NET Applications

Event Driven Programming – Writer Example

[PollingEventDriven, TransactionalEvent]public class PendingPostsProcessor{ [DataEventHandler] public Post ProcessPendingPost(Post post) { PostStatus newStatus = PostStatus.Published; foreach (String illegalWord in _illegalWords) if (post.Subject.Contains(illegalWord) || post.Body.Contains(illegalWord)) {

newStatus = PostStatus.Rejected;break;

} // Set new status: post.Status = newStatus; } return post;}

Page 20: Building Scalable .NET Applications

PosterLoad

Balancer

Read Life Cycle

WriterReader

SpaceIIS

Writer Client

ReaderClient

Post

Reader

PostPost

Page 21: Building Scalable .NET Applications

Users Load Balancer

Step II – Linear Scalability: Partitioning and Collocation

IIS Data Base

Writer

ReaderSpace

Writer

ReaderSpace

Writer

ReaderSpace

Writer

ReaderSpace

Writer

ReaderSpace

IIS

IIS

IIS• Collocation – write/read within the same process• Partitioning and Content-Based Routing• Async Writes to the Database

Page 22: Building Scalable .NET Applications

Users Load Balancer

Step III – Dynamic Scalability

IIS Data Base

Writer

ReaderSpace

Writer

ReaderSpace

Writer

ReaderSpace

IIS

MonitorProvision

• SLA Driven Policies• Dynamic Scalability• Self healing

Page 23: Building Scalable .NET Applications

Space Based Architecture Values

• Linear Scalability– Predictable cost model – pay per value

– Predictable growth model

• Dynamic– On demand – grow only when needed

– Scale back when resources are not needed anymore

• SLA Driven– Automatic

– Self healing

– Application aware

• Simple– Non intrusive programming model

– Single clustering Model

Page 24: Building Scalable .NET Applications

Questions?

Page 25: Building Scalable .NET Applications

GigaSpaces Home Page:GigaSpaces Home Page:http://www.gigaspaces.com/http://www.gigaspaces.com/

GigaSpaces XAP Product Overview:GigaSpaces XAP Product Overview:http://www.gigaspaces.com/wiki/display/XAP7/Concepts http://www.gigaspaces.com/wiki/display/XAP7/Concepts

GigaSpaces XAP for the Cloud: GigaSpaces XAP for the Cloud: http://www.gigaspaces.com/cloudhttp://www.gigaspaces.com/cloud