Mais conteúdo relacionado Semelhante a Crate Shared Nothing Web Backends - Web Backend Meetup May 2014 (20) Crate Shared Nothing Web Backends - Web Backend Meetup May 20143. Prepare for Workout
1.) bash -c "$(curl -L try.crate.io)"
https://cdn.crate.io/downloads/releases/crate-0.38.2.tar.gz
2.) sh$ bin/crate
0.) share our “craty” WLAN
pw: select*fromcrate;
6. Shared Nothing
Wikipedia:
!
a distributed computing architecture in which each
node is independent and self-sufficient, and there is no
single point of contention across the system. More
specifically, none of the nodes share memory or disk
storage.
8. Shared Nothing
Principle of most functional languages
Shared state/resources (memory) is what
makes threading hard
No SPOF
Easy concurrency
17. Shared Nothing with
Crate
data and query execution is
distributed among all nodes
no master/slave - all nodes are equal
automatic sharding & replication
21. Shared Nothing with
Crate
from sqlalchemy import Column, String, DateTime
from microblog.model import Base
import uuid
!
!
def genuuid():
return str(uuid.uuid4())
!
!
class BlogPost(Base):
!
__tablename__ = 'blogpost'
!
id = Column(String, default=genuuid, primary_key=True)
text = Column('text', String, nullable=False)
creator = Column('creator', String, nullable=False)
created = Column('created', DateTime, nullable=False)
22. Shared Nothing with
Crate
@rpcmethod_route(request_method="GET")
def list(self):
""" Return all blogposts
"""
query =
DBSession.query(BlogPost).order_by(BlogPost.created.desc())
blogposts = query.all()
result = []
for post in blogposts:
result.append({'id': post.id,
'created': post.created.isoformat(),
'text': post.text,
'creator': post.creator})
return {"data": {"blogposts": result}}