7. High Availability
A system that is designed for continuous
operation in the event of a failure of one or more
components. However, the system may display
some degradation of service, but will continue to
perform correctly.
High Availability: The proportion of time during
which the service is accessible with reasonable
response times should be close to 100%.
8. How to decide required scale
(capacity) & availability?
• Average throughput (TPS)
• Max throughput (TPS)
• Monetary value of a transaction
• Average loss & max loss per second of
downtime
• Decide on how much to invest based on cost
vs. benefit tradeoff
8
9. Vertical Scaling
• Get the maximum out of each allocated JVM or
resource
• Increase CPU size
• Increase memory
22. Object Pooling
• Some objects would be expensive to create
•
e.g. Connection objects
• Reuse objects
• State stored in those objects need to be
cleared before being returned to the pool
23. Lazy Loading
1. Lazy Initialization
A null field indicates that there is no data. When the value is
requested, a null check is performed to see if the actual
data needs to be loaded.
If(this.value== null) this.value = loadValue();
return this.value;
24. 2. Virtual Proxy
Lazy Loading
The virtual proxy implements the same interface as the real
object, and when called for the very first time, it loads the
real object & delegates to that object.
class VirtualProxy implements Interface {
private RealObject real;
private RealObject getReal(){
if(real == null) real = new RealObject ();
return real;
}
public void justDoIt(){
getReal().justDoIt()
}
}
class RealObject implements Interface {
public void justDoIt(){
System.out.println(“DONE!”);
}
}
25. Lazy Loading
3. Value Holder
A value holder is an object with a getValue method, which the
clients will invoke in order to obtain a reference to the real
object. Note that the method may not necessarily be named
getValue.
private ValueHolder<Widget> valueHolder;
public Widget getWidget {
return valueHolder.getValue();
}
26. Lazy Loading
4. Ghost
The real object without any data. The data is loaded as and
when required.
UUID id = UUID.getUuid();
String name;
Connection dbConn;
…
public Connection getDbConnection(){
If(dbConn == null) dbConn = loadDatabaseConnection();
}
31. Capacity Planning
Throughput = number of completed requests / time to complete the requests
No. of servers = (projected max load * 1.3) / max throughput of one server
max throughput of one server = max throughput of that server for the slowest
scenario in the set of use cases
33. Dynamic membership
• No predefined members
• Nodes can join & leave
Dynamic group
M1
M2
N
Join
M3
M4
33
34. Hybrid membership
•
Some predefined (well-known) members, and some
dynamic members
•
Nodes can join & leave
•
Membership revolves around the static members
Hybrid group
Dynamic members
M6
M5
M7
N
Static members
M1
M2
M3
Join (IP,
Port)
M4
34
36. Well-known Address (WKA) based
membership management
Hybrid group
Dynamic members
Static members
M6
N
WK1
M5
WK2
Notify
M7
Join (IP,
Port)
WK3
WK4
36
37. Multicast vs. WKA
Multicast
WKA
All nodes should be in the same subnet
Nodes can be in different networks
All nodes should be in the same multicast
domain
No multicasting requirement
Multicasting should not be blocked
No fixed IP addresses or hosts required
At least one well-known IP address or host
required
Failure of any member does not affect
membership discovery
New members can join with some WKA
nodes down, but not if all WKA nodes are
down
Does not work on IaaSs such as Amazon
EC2
IaaS-friendly
Requires keepalived, elastic IPs or some
other mechanism for remapping IP
addresses of WK members in cases of
failure
37
38. Auto-scaling
• Scale-out when load increases
• Scale-in when load decreases
• Always use the optimum amount of resources
• Try out
• AWS ELB
• Apache Stratos Load Balancer
• WSO2 ELB
54. Multiple IaaS (hybrid) Deployment
HIGHEST
Zone 1
Private cloud (data center)
Zone 2
Zone 1
Zone 2
Amazon EC2
Cost
LOWEST
Availability
Zone 1
Zone 2
Rackspace Cloud
54
56. Hazelcast
Clustering and highly scalable data distribution
platform for Java, which is:
Lightning-fast; thousands of operations/sec.
Fail-safe; no losing data after crashes.
Dynamically scales as new servers added.
Open source