Upload
tomas-zverina
View
5.157
Download
5
Embed Size (px)
DESCRIPTION
Tomuchovo prednaska o App Engine na GUG CVUT.
Citation preview
App Engine
Kick Start@tomucha
Multimedia atelier s. r. o.
Multimedia atelier s. r. o.
memeReactor
Cloud Computing
virtualization
SOA
SaaS
scalabity
distributed
YOU
YOURADMIN
Cloud Computing
Just like water from the tap in your kitchen, cloud computing services can be turned on or off quickly as needed.
Vivek Kundra, 1st CIO of USA
“It's stupidity. It's worse than stupidity: it's a marketing hype campaign.”
Richard Stallman, GNU founder
Škálovatelnost (nutná, ...)
12:00 18:00 24:00 6:00 12:00 18:00 24:00 6:00 12:00 18:00 24:00 6:00
Peak3 nodes
1 node
(… nikoliv postačující podmínka úspěchu)
12:00 18:00 24:00 6:00 12:00 18:00 24:00 6:00 12:00 18:00 24:00 6:00 12:00
TechCrunchefect
Škálování
Vertical scaling – posiluju počítač
Vertical partitioning – rozděluju služby
Horizontal scaling – přidávám nody
• load balancing
• dynamické škálování
• sessions
• database a další sdílené zdroje (FS, cache, ...)
• péče o hardware
Možnosti
Amazon Elastic Compute Cloud (Amazon EC2)
Amazon Simple Storage Service (Amazon S3)
Windows Azure
Rackspace.com
...
App Engine
Hosting
API / Framework
IDE plugin / SDK
App Engine vs. Amazon AWS
App Engine mrak strojů
hosting
storage
scalability
pay for what you use
different OS, languages
framework / API
App Engine – A jako v praxi teda?
WAR
App Engine – Omezení (Sandbox)
Bezpečnost
přístup na FS
práce se sockety
thready
java.lang.System / GC
reflexe
Škálovatelnost
NoSQL
joins, group by, agregate
unique
30s limit
quoty
App Engine – K čemu je, k čemu není
Jo
WWW
eShop
“Twitter”
“Flickr”
Ne
finanční software
UDP herní server
“YouTube”
velké výpočty
App Engine – Framework
Sessions – musí se zapnout
Images – manipulace alá Picassa
Channel – push to client (+ JS knihovna)
Mail / URLFetch / XMPP - komunikace
MemCache – distributed cache
Task Queue / Cron – asynchronní úlohy
Users – login via Google Account
Demo
http://code.google.com/appengine/
http://code.google.com/appengine/docs/java/tools/eclipse.html
Databáze
BigTable → BIG MIND SHIFT
• gigantická HashMapa HashMap
• WWW index, Earth, Finance, ...
nemá datový model
preindexed queries, joins, 2x “<”
přístup
• nativní API App Engine
• Java Data Objects – JDO
• Java Persistence Api – JPA
Databáze – Primary Keys
Key
• appId
• namespace
• Entity kind
• id / name
• parent
Entity employee = new Entity("Employee");
Entity employee = new Entity("Employee", "asalieri");
KeyFactory.createKey(Employee.class.getSimpleName(), "[email protected]");
Databáze – Transakce
Faktura
Řádek 1
Řádek 2
Produkt 1
Produkt 2
Entity Group
Databáze – JDO relationships
Owned One-to-One Relationships (záznam + detaily)
• jo – může přinést výhody
Owned One-to-Many Relationships (faktura + řádky)
• jo, vytváří EntityGroup
Unowned Relationships (člověk a oblíbené jídlo, n:m)
• ne-e, ručně, přes Key
Databáze - Optimistic Concurrency Control
int retries = 3;
while (true) {
Transaction txn = datastore.beginTransaction();
try {
// do stuff
txn.commit();
break;
} catch (ConcurrentModificationException e) {
if (retries == 0) throw e;
retries;
} finally {
if (txn.isActive()) txn.rollback();
}
}
memeReactor - pitevna
try {
chain.doFilter(hr, response);
} finally {
try {
final PersistenceManager pm = PMF.get();
if (pm.currentTransaction().isActive()) {
pm.currentTransaction().rollback();
}
} catch (Exception e) {
}
PMF.close();
}
memeReactor - pitevna
transaction(new TransactionCallback() {
@Override
public void runInTransaction(PersistenceManager pm) {
// do stuff
}
});
Begin, Commit, Rollback, repeat, ...
AppEngine - tipy
Zapomeňte na SQL a normální formy (s rozmyslem)
• denormalizace
• kolekce a pole jako datový typ
Zapomeňte na ORM (nebo alespoň relationships)
Testujte “pod zátěží” a ne jen na localhost
<%@ page contentType="text/html;charset=UTF8" language="java" isELIgnored="false" %>
Q&A