2. 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:
– guyn@gigspaces.com
– @gnirpaz – Twitter
– jroller.com/gnirpaz - Blog
3. 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
4. Explore technical and business
challenges of building scalable
applications. Analyze fundamental
architecture limitations and propose
cost-effective alternative
7. Traditional Tier Based Architecture is not scalable
Business tier
• Relies on centralized resources
• HardTier install:
to
Web
• Bound to static resources (IPs, disk drives,
Load
Balancer
etc.)
• Separate clustering model for each tier
• Hard to maintain Back-up
Back-up
• Non-scalable Back-up
Messaging
10. Micro-Blogging (ala Twitter) Example
Read
Service
IIS
Publish
Service
Load
Users
Balancer Application
Data
Base
Read
Service
IIS
Publish
Service
Application
12. What happens on success
Users
Read The database becomes
Service
the bottleneck
Read
IIS Service
Publish
Service
Load IIS Publish
Balancer Service
Application
Data
IIS Application
Base
Read
Service
Read
IIS Service
Publish
IIS Service
Publish
Service
IIS Application
Application
13. Reader – Database Implementation
public ICollection<Post> GetUserPosts(string userID, DateTime
fromDate)
{
// Create command:
IDbCommand dbCommand =
_dbConnection.CreateCommand();
dbCommand.CommandText = String.Format(
quot;SELECT * FROM Post WHERE
UserID='{0}' AND PostedOn > {1}quot;,
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;
}
14. Step I – Remove DB Bottlenecks with Caching
• Reduce I/O bottlenecks – less
DB access
• In-Memory caching
Load
Users
Balancer
• Reduced Network hops (if in-
Read Cache
Data
IIS Service
Service
process) Base
Publish
• Suitable for read-mostly apps
Service
Application
15. 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;
}
16. Step II – Linear Scalability: Partitioning and Collocation
Reader
Space
Writer
Reader
Space
Writer
IIS
Load
Users
Balancer
Reader
Space
IIS Data
Writer
Base
IIS
Reader
Space
IIS Writer
Reader
Space
Writer
17. Post Life Cycle
Reader Writer
Poster
Load Post.NEW
Balancer Reader
Client
Post.VALID
Writer
Client
Space
IIS
Reader
18. Writer Client
public class SpacePublisherService : IPublisherService
{
private readonly ISpaceProxy _spaceProxy;
public void PublishPost(Post post)
{
this._spaceProxy.Write(post);
}
}
19. 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;
}
20. Read Life Cycle
Reader Writer
Poster
Load
Balancer Reader
Client
Writer
Post
Client
Post
Space Post
IIS
Reader
21. Step II – Linear Scalability: Partitioning and Collocation
Reader
Space
Writer
Reader
Space
Writer
IIS
Load
Users
Balancer
Reader
Space
IIS Data
Writer
Base
IIS
Reader
Space
• Collocation – write/read
within the same process
IIS Writer
• Partitioning and Content-Based Routing
Reader
Space
• Async Writes to the DatabaseWriter
22. Step III – Dynamic Scalability
Monitor
Provision
Reader
Space
Writer
Load
Users
Balancer
Reader
Space
IIS Data
Writer
Base
IIS
Reader
Space
• SLA Driven Policies Writer
• Dynamic Scalability
• Self healing
23. 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