欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2/Agda, C++/Lisp/Haskell
Apache Usergrid
Apache Usergrid 是一个面向web和移动应用的多租户 Backend-as-a-Service 堆栈,基于 RESTful APIs,使用 Apache Cassandra 做后端存储。
目录 |
简介
Apache Usergrid — the BaaS not made for Hipsters
新闻
- Apache Usergrid moved into the Attic in 2021-12. 项目已经退役关闭和存档,不再维护
- Google is sunsetting the Apache Usergrid based API BaaS service (May 18, 2018)
版本
new "core persistence" engine in Usegrid 2.1 has been under development for two years now. Internally, this new engine provides a set of new modules for Entity Collections, Graph database, Maps, Query-Index, Queues and Caching. The core persistence design favors simple and composable operations that can be made asynchronous via RxJava, uses Multi-Version Concurrency Control (MVCC) to avoid use of locks and the Query-Index module relies on Elasticsearch.
- 2.0
- 1.0
应用对象
Usergrid提供了一组核心应用程序对象,主要实现了对用户的管理以及对交互性的增强、通过自由的数据存储系统存储数据、检索以及返回任何类型的内容和对象集合等。Usergrid也提供了对日志数据的支持,这使得实时事件分析和关键指标的跟踪成为可能,这块可考虑由KairosDB提供服务。
应用对象(Data Entity Types)包括:
- 用户(user)
- 用户组(group)
- 角色(role)
- 应用(application)
- 行为(activity)
- 设备(device)
- 资源(asset)
- 目录(folder)
- 事件(event)
- 通知(notifier)
- 通告(notification)
- 收到(receipt)
每个对象都被保存在其各自的集合中(/users,/groups……)。Usergrid也允许创建用户想要的任何类型的动态(自定义的)实体。动态实体会被自动保存在以实体类型复数为名称的集合中。
所提及的消息(message)概念是以notifier、notification、receipt数据实体类型体现。
Activity Streams
Activity是一个代表Activity Stream actions的实体类型。
Activity Streams 用来描述一个社交网络中的个体的一系列活动。比如 Facebook 的 News Feed(新鲜事)就是一条 Activity Streams 消息。目前 Activity Streams 已经成了 OpenSocial 的标准数据格式并被广泛地支持。Activity Streams entry 元素总是包含三个主元素,它们分别是:actor,即执行动作的人,例如:DoctorWang;verb,即执行的动作类型,例如:admit;object,即动作所针对的对象,例如用户 John。
授权
Usergrid的API实现了OAuth 2.0的授权模型,所有的请求都需要带有有效的访问令牌。
消息
Usergrid提供了一个消息队列服务,该服务为保证高扩展性的同时向应用中分发消息所设计。此外为了使消息队列服务具备一定的灵活性,还将会增加客户通知、社交收件箱、内容源、评论功能以及其他一些常见的消息队列操作。该框架支持使用Websocket来进行实时处理。
集成RabbitMQ
Spring
Spring承担了Usergrid核心框架的重任。
REST API
- Usergrid REST API Web App
- REST API v2
- Usergrid REST API 构建在 Jersey 之上。
- Jersey @ Usergrid
- Jackson 处理 JSON 数据。
服务层
- Usergrid Services Layer
- 用户和组权限建立在Apache Shiro之上。
SDK
Dart & Flutter
iOS
Android
H5/JS
Node.js
Go
- 基于REST API,支持 Go 语言,提供 Go SDK。
- 集成 Go 提供的高并发处理基础设施。
Scala
集成 Scala
Clojure
集成 Clojure
安装
指南
确保已正确安装 Apache Cassandra,下载usergrid包并解压 或直接下载二进制压缩包,参考Usergrid 2.1.0安装部署。此外,Usergrid 1.x安装部署。
cd sdks/java mvn clean install cd stack mvn clean package -DskipTests=true //cd launcher; java -jar target/usergrid-launcher-*.jar // Usergrid 1.x 版本 cp stack/rest/target/ROOT.war 到 tomcat7/webapps 然后完成下面配置并重启。 curl http://localhost:8080/status curl -X POST \ -d 'organization=myfirstorg&username=myadmin&name=Admin&[email protected]&password=password' \ http://localhost:8080/management/organizations curl 'http://localhost:8080/management/token?grant_type=password&username=myadmin&password=password'
你也能以 tomcat webapp 的方式运行, 移除 tomcat/webapps/ROOT 下的内容,将 usergird/rest/ROOT.war 拷贝到这
cd tomcat/lib 创建 ____usergrid-custom.properties____
usergrid.sysadmin.login.allowed=true usergrid.sysadmin.login.name=superuser usergrid.sysadmin.login.password=pw123 [email protected] [email protected] usergrid.management.mailer=Myself<[email protected]> [email protected] usergrid.test-account.admin-user.password=test
数据库设置
http://localhost:8080/system/database/setup curl -X PUT http://localhost:8080/system/database/setup -u superuser:test curl -X PUT http://localhost:8080/system/database/bootstrap -u superuser:test curl -X GET http://localhost:8080/system/superuser/setup -u superuser:test
管理员设置
http://localhost:8080/system/superuser/setup
控制台, 配置文件 usergrid-custom.properties
http://localhost:8080/usergrid-portal
单独运行一个轻量server
cd portal ./build.sh dev http://localhost:3000/index-debug.html http://localhost:3000/
部署方式
- AWS Cluster
- Apache HTTPD, Tomcat
- Nginx + Jetty
Elasticsearch
Cassandra
- Apache Cassandra 提供存储服务
- 使用Netflix Astyanax Cassandra Java Client
集群
性能
- Scaling Usergrid to over 10,000 requests/second - Part 1 10,268 Requests Per Second with 35 c3.xlarge Usergrid servers and 9 c3.4xlarge Cassandra nodes.
- 引入Akka高并发框架。
Akka
Apache Usergrid 2.1.1在corepersistence持久化框架中引入Akka actorsystem
RPC
- Cassandra RPC 9160端口
- 参考猎豹移动的Go架构
- grpc和go语言实现
- grpc-java
开发者
- Usergrid Creator, Ed Anuff, Open Source Mobile Backend on Cassandra @GitHub
- 开发者
用户
文档
- Building Your Own BaaS With Apache Usergrid & Docker: Lessons Learned At Scale
- How to Contribute to Apache Usergrid
- Apache Usergrid Internals
- Open Source Mobile Backend on Cassandra
- Cassandra Data Modeling Best Practices at eBay Cassandra at eBay Cassandra Scale at eBay