What is cloud
computing?
What is
The Cloud?
These are separate questions...
Someone else's hard drive
Abstracting away physical infrastructure
Disposable application design
Your application is disposable.
Your data is not.
You don't get an in-between option
Cleanly separate "Dev provided" and "user provided" files
Does config come from the developer or the user?
Git or Database?
Decide
// PHP
getenv('foo');
// Node.js
process.env["foo"];
// Go
os.Getenv("foo");
// Java
System.getEnv("foo");
Etc.
Need glue code
// platform_parameters.php
if (getenv('PLATFORM_RELATIONSHIPS')) {
$relationships = json_decode(base64_decode(getenv('PLATFORM_RELATIONSHIPS')), true);
foreach ($relationships['database'] as $endpoint) {
if (!empty($endpoint['query']['is_master'])) {
$container->setParameter('database_driver', 'pdo_'.$endpoint['scheme']);
$container->setParameter('database_host', $endpoint['host']);
$container->setParameter('database_port', $endpoint['port']);
$container->setParameter('database_name', $endpoint['path']);
$container->setParameter('database_user', $endpoint['username']);
$container->setParameter('database_password', $endpoint['password']);
break;
}
}
}
$container->setParameter('kernel.secret', getenv('PLATFORM_PROJECT_ENTROPY'));
composer require platformsh/symfonyflex-bridge
function mapPlatformShEnvironment() : void
{
$config = new Config();
$secret = getenv('APP_SECRET') ?: $config->projectEntropy;
setEnvVar('APP_SECRET', $secret);
$appEnv = getenv('APP_ENV') ?: 'prod';
setEnvVar('APP_ENV', $appEnv);
mapPlatformShDatabase('database', $config);
if (!getenv('MAILER_DSN')) {
mapPlatformShMailer($config);
}
}
// ...
const platformsh = require('platformsh-config');
let config = platformsh.config();
const credentials = config.credentials('database');
const connection = await mysql.createConnection({
host: credentials.host,
port: credentials.port,
user: credentials.username,
password: credentials.password,
database: credentials.path,
});
var app = express();
// ...
app.listen(config.port);
package conf
import (
psh "github.com/platformsh/config-reader-go/v2"
)
var PshConfig = createPshConfigObj()
func createPshConfigObj() *psh.RuntimeConfig {
config, _ := psh.NewRuntimeConfig()
return config
}
package main
func main() {
engine := gin.Default()
// ...
err := ginInstance.Run(":" + conf.PshConfig.Port())
}
package sh.platform.template;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import sh.platform.config.Config;
import sh.platform.config.MySQL;
import javax.sql.DataSource;
@Configuration
public class DataSourceConfig {
@Bean(name = "dataSource")
public DataSource getDataSource() {
Config config = new Config();
MySQL database = config.getCredential("database", MySQL::new);
return database.get();
}
}
Use DotEnv (.env
files)
(Many to pick from in every language)
(App-specific configuration)
Constants? Static config files?
Dependency inject your environment
Cloud
Always be able to
take your business elsewhere.
Use Free Software
Use replaceable services
Source: WordStream (2015)
There is no industry consensus yet regarding the properties of microservices, and an official definition is missing as well.
(Sources: Wikipedia, Martin Fowler)
Every microservice treats every other microservice as a separate 3rd party
that may as well be a different company.
Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.
"If one of your microservices going down means the others don't work, you don't have a microservice; you have a distributed monolith."
—A few dozen people
So if microservices aren't for me, what is?
You've probably already done this
Cron jobs
"Admin" application
Queue workers
API app
All asynchronous
Remember what they say when you assume
Director of Developer Experience Platform.sh
The end-to-end web platform for agile teams
Stalk us at @PlatformSH