1. 9 Design factors on
developing Cloud
applications
Feb 2017
Rick Jang
2. 9 Design factors on developing cloud
applications
1.Don't code your application directly to a specific topology
2.Do not assume the local file system is permanent
3.Don't keep session state in your application
4.Don't log to the file system
5.Don't assume any specific infrastructure dependency
6.Don't use infrastructure APIs from within your application
7.Don't use obscure protocols
8.Don't rely on OS-specific features
9.Don't manually install your application
2
3. Design factors on developing cloud applications
Don't code your application directly to a specific topology
ïš Use Dynamic Service Binding e.g. Spring DI
3
4. Design factors on developing cloud applications
Do not assume the local file system is permanent
ïš Use File Storage Services like Amazon S3
4
5. Design factors on developing cloud applications
Don't keep session state in your application
ïš Use Memory Cache Service like ElastiCache
ïšWhen you use Cloud Foundry Auto re-configurer,
Session cluster service (Redis) is automatically bound for
java sevlet Session.
Ref. https://blog.pivotal.io/pivotal-cloud-
foundry/products/session-replication-on-cloud-foundry-2
5
6. Design factors on developing cloud applications
Don't use obscure protocols
ïš Use 80, 443 ïš make as a Micro Service
6
7. Design factors on developing cloud applications
- 9
Don't manually install your application
ïš Automatically Install your application
dependencies such as DDL, static files
ïšYou can use JPA which automatically installs your
entities by generating DDLs
ïš The spring-music.war example shows
automatically installs the static data when it is
connected to MySQL service.
7
9. Example SaaS App â Essencia Project Management Tool â MSA Architecture
Amazon S3 Clear DB
Redis
Memory Cache
Essencia Service
3rd Party Apps
JIRA Issue Tracker
Service
All RESTful
11. Example SaaS App â Essencia Project Management Tool â On-premise Architecture
Local File System
Local DB
(MySQL)
Essencia on-premise
IStorage DataSource HttpSession
LocalFileStorage org.apache.catali
na.session.Stand
ardSession
DBCPDataS
ource
<bean id="storage" class="org.uengine.modeling.resource.LocalFileStorage"
<property name="localBasePath" value="D:Projectcodi"/>
</bean>
12. Essencia - Dynamic Service Binding with
Spring DI
<bean id="storage"
class="org.uengine.modeling.resource.AmazonS3Storage">
<property name="amazonS3Bucket"
value="${Amazon.S3.Bucket}"/>
<property name="awsAccessKey"
value="${Amazon.AccessKeyID}"/>
<property name="awsSecretAccessKey"
value="${Amazon.SecretAccessKey}"/>
</bean>
<bean
class="org.cloudfoundry.reconfiguration.spring.AbstractCloudService
BeanFactoryPostProcessor" />
<bean id="storage"
class="org.uengine.modeling.resource.LocalFileStorage">
<property name="localBasePath" value="D:Projectcodi"/>
</bean>
Case of On-premise Case of On Cloud
13. Essencia â Application Code must not be
affected
@Autowired public Storage storage;
public void delete() throws IOException {
storage.delete(this);
}
14. Essencia â Using AOP for Metering /
Billing â 1
@Metered("project.start")
public void executeProcess(String instanceId) throws Exception{
ProcessInstance instance = getInstance(instanceId);
instance.execute();
}
15. Essencia â Using AOP for Metering /
Billing â 2
@Aspect
public class MeteringAdvice {
@Before("@annotation(metered)")
public void checkAvailable(Metered metered) throws
NoServiceAvailableException {
âŠ..
//Check if the service is available for the requested tenant
}
@AfterReturning("@annotation(metered)")
public void meter(Metered metered) throws Exception {
âŠ.
//Add usage log
}
}
16. Essencia â Build & Deploy Automation
Essencia On-Premise
Essencia On Amazon
Essencia On Bluemix
Overrides:
1. applicationContex.xml (to use AmazonS3Storage)
2. Uengine.properties (to change DB connection info)
Overrides:
1. applicationContex.xml (to use services)
2. pom.xml (Cf push command)