13. “Offline First is the new Mobile First”
by Michael Hart,
Senior Software Development Manager
Predix Experience, General Electric
14. Couchbase Connect 2015 GEセッション資料「Offline First: How GE Integrated Couchbase Mobile in Less Than 90 days」から引用
http://www.slideshare.net/Couchbase/offline-first-how-ge-integrated-couchbase-mobile-in-less-than-90-days-couchbase-connect-2015
15. Couchbase Connect 2015 GEセッション資料「Offline First: How GE Integrated Couchbase Mobile in Less Than 90 days」から引用
http://www.slideshare.net/Couchbase/offline-first-how-ge-integrated-couchbase-mobile-in-less-than-90-days-couchbase-connect-2015
16. Couchbase Connect 2015 GEセッション資料「Offline First: How GE Integrated Couchbase Mobile in Less Than 90 days」から引用
http://www.slideshare.net/Couchbase/offline-first-how-ge-integrated-couchbase-mobile-in-less-than-90-days-couchbase-connect-2015
17. The Motley Fool 「What Internet of Things (IoT) Investors Need to Watch in 2015」から引用
http://itpro.nikkeibp.co.jp/atcl/column/15/032400051/032400001/
18. GE公式ブログ「GE’s Industrial Internet Just Got Real: 14 New Applications That Could Boost
GDP by $10-15 Trillion」から引用http://blog.pivotal.io/pivotal/p-o-v/ges-industrial-internet-just-got-real-14-new-
applications-that-could-boost-gdp-by-10-15-trillion
33. Couchbase Connect 2015 GEプレゼン資料「Offline First: How GE Integrated Couchbase Mobile in Less Than 90 days」から引用
http://www.slideshare.net/Couchbase/offline-first-how-ge-integrated-couchbase-mobile-in-less-than-90-days-couchbase-connect-2015
当社についてご存じない方もいらっしゃるかと思いますので、簡単に会社の説明をします。
Couchbaseは2011年にMembase社とCouchOne社が合併(がっぺい)して設立(せつりつ)されたNoSQLデータベースの開発・提供をしている会社です。(http://jp.techcrunch.com/2011/02/08/20110207nosql-companies-couchone-and-membase-merge-to-form-couchbase/)
NoSQLの業界では比較的まだ新しい企業になりますが、米国に本社を置き、欧米諸国(おうべいしょこく)、アジア圏(けん)にもサービスを展開しているグローバル企業です。
今回紹介させて頂きますNoSQLのモバイルソリューションは世界初、NoSQLベンダー唯一のソリューションとなり、米国本社の設立当初にはNTTドコモ様に資金(しきん)提供を受けています。
Couchbase Japan株式会社は昨年4月に設立され、日本国内でもビジネスを広げるためこのようなカンファレンスや勉強会などでCouchbaseを紹介させて頂いています。
それでは、Couchbaseモバイルソリューションについて解説をする前に、当社のモバイルソリューションを導入されているゼネラルエレクトリックの事例を紹介したいと思います。
We’ve been growing very fast. From just 7 employees in 2010, we’re now over 300 and counting, with people in North America, Europe, the Middle East, and Asia.
But what we’re most proud of is our customer growth, which has skyrocketed at over 100% year over year.
growth: 25 in 2010, to 430+ in 2014
IoTにご関心のある皆様なので既にご存知の方もいらっしゃるかもしれませんが、昨年10月にゼネラルエレクトリックはエネルギー、運輸、航空、ヘルスケアなど40種類にも及ぶIoTソリューション「Predix(プレディクス)」の提供を開始しました。
GEはご存知の通り、医療、環境、重工業(じゅうこうぎょう)、航空運輸など様々な分野でビジネスを展開するグローバル企業ですが、これら業界向けにセンサーの設置、収集、分析、活用を目的としたサービスがこのPredixです。Predix開発のために1000人ものエンジニアを増員したという記事もありましたので、GEがこのIoTソリューションに非常に力を注いでいるのが分かります。(http://coin.nikkeibp.co.jp/coin/nis/1401/pdf/sample2.pdf)
そしてこのPredixを裏で支えているのがCouchbaseモバイルソリューションです。
サービス提供開始からわずか数ヶ月後にソフトバンクもこのPredix専用の海運(かいうん)や製造分野向けアプリ開発のライセンスを契約していますので、日本の皆さんも気がつかないうちにCouchbaseのモバイルソリューションを使用しているかもしれません。(http://goo.gl/82wO3d)
それでは、Couchbaseモバイルソリューションの解説の前に、もう少しGEのIoT基盤Predixについてお話したいと思います。
GE, one of the largest companies in the world, operates several large business segments including Energy, Transportation and more.
In October 2014, they started to provide IoT platform called “Predix” for their customers such as medical/healthcare, environment, airplane, etc.
A report said that GE hired additional 1000 engineers for this project, and we can easily understand that GE is focusing a lot of resources on Predix.
And Couchbase Mobile Solution is supporting GE’s IoT platform.
Within a few months after the first release, the third largest telecom company, Softbank, had a license agreement to build mobile app for shipping or manufacturing on Predix.
So without being noticed, you might have already used our mobile solution though Predix.
So let me talk a little more about Predix before getting into Couchbase Mobile Solution.
-------------------------------------------------------------------------------------------------------------
*Below is Ali’s note;
What I’m going to talk about today is their Predix platform and how they use Couchbase Mobile to enable some really powerful capabilities.
Predix is GE’s software platform for the Industrial Internet. It connects things like trains, wind farms, submarines, and so much more. All kinds of things that are counted on to work all day, everyday for the next 25, 30, 35+ years...
Connectivity is mission critical – these machines are literally everywhere. The middle of the ocean, the top of a mountain, inside of a turbine, or in a rail yard. And even then, those machines have hundreds of moving parts, all of which need to be tracked and maintained.
So what Predix does is ingest all this data, stores it, cleans it, analyzes it and takes all of this critical information back to the operator. And it provides that information at massive scale. So Predix must be reliable, 24/7.
GEは2012年11月から今回のIoT基盤Predix開発のきっかけとなる「インダストリアル・インターネット」を提唱しています。
この図はITProの記事から引用させて頂いていますが、この図の通りインダストリアル・インターネットの中核である共通プラットフォームがPredixです。
このインダストリアル・インターネットとは、様々な製品から稼働データなどを収集してビッグデータを分析、運用し、保守や次の製品開発に生かす構想(こうそう)を意味します。
図にある通り、まずセンサーを埋め込んだ各種機器からネット経由で様々なビッグデータを安価に収集し蓄積します。
そしてそのデータの分析によって、機械の故障を事前に見極めたり、点検を促すなどして、現場でのアクションをより効率化することに繋がります。
GE has been proposing the idea called “Industrial Internet” since November 2012, and this is the core idea to develp Predix.
As you can see in the image, Predix is the core technology forming Industrial Internet. (sensors (devices) > big data (storage) > analytics (BI) > actionable info (mobile)
Industrial Internet means that sensors generated from industrial machines will be collected to database (data lake), then analyzed so that field engineers can make action for maintenance or sometimes even to improve their services in future.
Data can be also used to provide information to field engineers to check machiens before they have problems.
これは鉄道が積み荷の運搬(うんぱん)のため、車庫からどのレールに配置されるかというオペレーションをイメージしています。
The rail yard worker is using this app, powered by Predix, to manage and direct these tasks. Network connectivity is not reliable, but the app must always work to ensure tasks are completed reliably and on time.
And this is just one example – all of these types of apps must always work, regardless of network availability. Like I mentioned earlier, the machines that Predix powers can be anywhere and network connectivity is not guaranteed.
Here’s an example of an application that could be built using the mobile features of Predix.
Let’s say that this application manages tasks assigned to workers in a trainyard. Let’s walk through how it work.
This is a diagram of a simple rail yard where traincars can be dropped off for routing.
A worker has a mobile device that serves up their tasks.
モバイル端末の活用が飛躍的(ひやくてき)に伸びたのは、2007年Apple社のiPhoneの発売がきっかけではないでしょうか?
それ以降、モバイルアプリの動作の主流はRESTに頼っています。
そのためWebアプリ同様、モバイルアプリもインターネットに繋がっていないと使用できない作りになってしまいました。
2010年になるとクラウドなど別の場所にデータを移動する手段(しゅだん)がでてきます。
実は、このアプローチは1990年代後半にエンタープライズ企業、例えばSiebel, Oracle, SAPが既に行っていたことでもありました。
それがインターネットの急速な普及により同期のアプローチからオンライン作業のみのアプローチに移り変わったのですが、現在そのサイクルがまた「オフライン」アプローチに変わりつつあり、電波の有無や安定に関わらず使用できるソリューションが必要になってきました。
The beginning of time in mobile as we know it today was 2007, with the release of the first iPhone.
From 2007 through today, the primary way to power mobile apps is via REST.
And while REST allows developers to take this proven architectural approach and apply it to mobile platforms, it also means that mobile apps (like web apps), will only work when you have a network connection.
Then we got to 2010, where there was a shift in sync capabilities that would move data to and from other endpoints, like the cloud.
For the record, this wasn’t a new approach but more of a reemergence of the enterprise sync technologies of the late 90s.
Back then, you would see companies like Siebel, Oracle, SAP and others use local data and sync technology to enable remote sales forces on their laptops. And there are a lot of other examples.
But then that sync kind of died off with the shift to web apps and the promise of ubiquitous wireless networks.
So going back to today, there’s now the shift towards an offline-first enterprise. Mobile apps have to work with and without a network connection.
現在のモバイルアプリはリモートデータを使う時に、つまりサーバからのダウンロードやローカルデータのアップロードを行う時にネットワークが繋がっていないといけません。
速度が足りるネットワークが接続されていればアプリは通常に動き、それはそれで問題ないですが、ネットワークが混乱している場合、電波が悪くなったり、WiFiにたくさんの人が接続していたりするとアプリの反応が悪くなってしまいます。その時点で、接続中を表すぐるぐる回るアイコンが出て待つ場合が多くなります。
さらに悪化すると「接続できませんでした。また後でやり直してください」というメッセージが表示されます。作業中だった内容が失われ、ユーザーを困らせてしまうだけではなく会社にとって経済的な損失にもなる可能性があります。
Note: Subway, driving in the mountains, theme park, underground conference room, shopping mall, warehouse (construction interfering with signal), etc
Most of today’s mobile apps are designed so that any remote data, whether downloading records from a server or uploading your local data, requires the network to be available and online.
As long as that’s the case, and the Internet connection is fast enough, and there aren’t any problems, then the app performs exactly as expected—and that’s great.
But as soon as the network begins to degrade, say we’re down to just a couple of tower bars, or the Wi-F is having a bunch of latency—that sort of thing—then we start to see the app’s user experience break down. That’s when we see the progress notification UI hints show up, the spinners, the waiting.
If things get bad enough, we will see an error message saying that, “I’m sorry you can’t do what you were trying to do right now, you’ll have to try later.” Whatever work you were doing is lost, and the end result is a user who is unhappy and dissatisfied and can use your app.
GEの提供する鉄道、航空、環境ビジネスなどに限りません。
インターネットの繋がらない環境はもちろんですが、建物の中、飛行機など高いところ、地下鉄、カンファレンスや遊園地などネット利用者が密集(みっしゅう)している場所、年末年始などメッセージのやり取りする時間帯が通常より集中するケース、作業現場など遠隔地(えんかくち)で電波が安定していない場所、更に基地局(きちきょく)の隙間(すきま)や、逆に基地局が多いところでも電波同士の干渉(かんしょう)でネットに繋がりにくくなることもあります。
このような電波が繋がりにくい場所でも、業務中やプライベートに関わらずモバイル端末を使用する必要は出てきます。
We are not only talking about GE’s industrial service such railway, airplane, or oil/gas business.
There are a lot of places where internet connections are unstable such as; inside building, in a airplane, subways, crowded places like conference room or theme park, specific event date/time like New Year’s as many greeting messages, field work places, between base station antenas, or even where there are too many base station antenas.
With or without internet connectivity, business or private, mobile app needs to keep running so that people are comfortable of using it.
このように電波に依存していては繋がったり、繋がらなかったりではなかなか作業がはかどりません。
オンライン・オフラインに関わらずモバイル端末を使って作業を行うことができるようにするのがCouchbaseのモバイルソリューションです。
It’s very irritating if I have to depend on connectivity to do work.
With Couchbase Mobile Solution, you have no stress to work at anytime, anywhere, without being aware that you are online or offline.
それでは、Couchbaseのモバイルソリューションがどのように機能するか、どのような場面で使用することができるかについて技術的な観点(かんてん)からもう少しお話したいと思います。
Couchbase Mobile is our answer to that problem, and we think you’ll love it as much as we do.
So, what it does it do, and how does it work?
CouchbaseのモバイルソリューションはCouchbase Lite, Sync Gateway, Couchbase Serverの3つの製品から成り立つ1つのソリューションです。
CBLはモバイル端末で動作するローカルのNoSQLデータベース、Sync Gatewayはモバイル端末とサーバ間の同期、Couchbase Serverはドキュメント指向のNoSQLデータベースです。
今回は世界で初のモバイル端末上で稼動してローカルにデータを保存するNoSQLデータベースCouchbase Liteと、ローカルデータベースとサーバの間で同期の役割をするSync Gatewayについて解説します。
This workshop introduces the world's first embedded NoSQL solution: Couchbase Mobile. The complete Couchbase stack consists of three parts: Couchbase Lite, Sync Gateway, and Couchase Server.
In this workshop, we will introduce Couchbase Lite (an embedded NoSQL DB) which lives on mobile devices and Sync Gateway which functions between Couchbase Lite and the cloud NoSQL database, Couchbase Server.
We have Couchbase Lite, which runs on the device
And we have Sync Gateway, which stands on the border between your private cloud and the public cloud.
Couchbase Liteは世界で初めてのNoSQLモバイルデータベースです。別プロセスではなくアプリに組み込まれるためフットプリントが小さいのが特徴です。
そして機能は主に4つ分かれています。
ドキュメント指向データベース
MapReduceクエリのエンジン
様々な変更通知
マルチマスター同期
それでは各項目について詳細をお話したいと思います。
Couchbase Lite is the world first NoSQL mobile database which means it runs in process with your application, and it has a very small footprint.
We have four major feature areas:
1. It is a document oriented database
2. It provides a Map Reduce query engine
3. It provides a suite of event notifications
4. It provides sync (multi master replication)
まず始めに機能の1つ、ドキュメント指向データベースを紹介したいと思います。
Couchbase Liteは世界で初のドキュメント指向のモバイルデータベースで、KV構造、スキーマレス、開発スピードや動作の高速化などの特徴が挙げられます。
リレーショナル・データベースの世界ではテーブルとそのテーブル内の関係を定義するかと思いますが、アプリのオブジェクト・モデルのためにデータを取得する際にO/Rマッピングを行う必要がありますので、コードが増えてしまいます。
反対に、ドキュメント指向データベースはアプリと同じデータ構成を使います。具体的にはキー・バリューのコレクションを指します。つまりiOSだとNSDictionary、JavaだとMapで.NETだとDictionaryです。
キー・バリューコレクションである上にキー・バリュー・ペアの変更をモニタリングするためにバージョン履歴をドキュメント毎に書き込みます。
O/Rマッピングなど関係なくなります。キー・バリュー・ペアの使い方さえ分かれば問題ありません。そして、再帰的にオブジェクトを突っ込みますのでJOINなどの心配はする必要がなくなります。メモリに必要な情報を直接入れることができますので、スキーマの整理や正規化と非正規化がなく、アプリのロジックがより簡単になります。
それによって開発も動作も早くなります。Couchbase LiteはオブジェクトモデルをJSONで保存しています。開発者はJSONに使い慣れているので違和感無く始められるかと思います。更に、データベースはJSON対応してますので、開発スピードも、動作もはるかに高速になります。
GEでは既存のシステムからこのCouchbaseモバイルへの移行へ決断するのに1日、検証に5日、データ以降に30日、その他機能面などの調整や移行などで計90日でプロジェクトを完成させたそうです。Predixは冒頭(ぼうとう)で紹介したように重工業向けのかなり大規模(だいきぼ)かつ様々な分野を対象にしたプラットフォームであるのに関わらず、これほど早く開発ができたのはまさにNoSQLの恩恵を受けたからと言えるかと思います。
Let’s talk about Document Oriented Database.
If we are coming from a relational model, we are familiar with modeling our data in third model form, where we have a number of tables and we define all of these relationships between the tables. When we need to retrieve the data from these normalized database schemas into our object model in-memory, we go through some object relational mapping (it’s a lot of cruft to keep up with).
In contrast, the document oriented database, uses the data structure we are already using in our applications. More specifically, it is a collection of key-value pairs. In iOS, you’re looking at an NSDictionary, in Java you are looking at a Map, and in .NET you’re looking at a Dictionary.
In addition to being a key-value pair collection, we also add in to documents a version history, so we can track the changes in that key-value pair all the time.
We don’t have to deal with normalizing data anymore. We only need to know how to use a key-value pair. Because we insert nested object graphs within that key-value pair, we don’t need to worry about joins and things like that. What ever object graphs we need to have in-memory, we just store in the key-value pair collection. This vastly simplifies how we build our applications because we no longer have to deal with the book keeping aspects of schemas and the problems of going between normalized data and de-nomalized data.
That lets us code fast and run fast. Internally on disk, we use JSON serialization to represent the object model. We are using whatever basic skills you are already familiar with in dealing with JSON data, but we’ve taught our database how to deal with JSON data so it’s fast.
次に2つ目の機能であるMapReduceインデックスについて説明します。
まず、MapReduceインデックスはネイティブ言語で開発することが可能です。つまりMapRecuceのインデックスを作るのに新たに他の言語を習得する必要がないため、開発を非常に効率的に行うことができます。
また、MapReduceインデックスによってドキュメントの素早いクエリを行うことができます。結果は保存されますのでクエリは超高速です。
最後に、このMapReduceインデックスを使うとデバッグが非常に効率的にできるようになります。別の組み込みSQL言語を頼りにすると、遅くなったり違う結果が出てしまっても直接操作できるデバッグ方法がありません。成功するのに試行錯誤(しこうさくご)するしかないのがとても不便です。MapReduceクエリエンジンを使うとツールと同じデバッガーを使うことができます。そしてどこでおかしくなっているか知りたい場合はブレークポイントを設定するだけでデバッグを行えるので非常に便利です。
MapReduce Indexes: provide us the mechanisms for doing very fast queries against our documents. This lets us build our indexes in our native language. When we’re dealing with two languages, we have to resort to an embedded string-based language for SQL that works completely different, and we have no direct way of being able to debug why an index is slow or why it’s not returning the correct results. We have to do a lot of trial and error to get it right.
By providing a MapReduce query engine, we’re able to use the same debugger, the same tools we are already using.
The results are persisted, so your queries are lightening fast.
If we’re trying to figure out where things are going on, all we have to do is set up breakpoint.
3つ目のCouchbase Liteの特徴は変更通知です。
Couchbase Liteのオブジェクトにはそれぞれの開発言語の標準のイベントシステムによって変更通知の登録、監視を行うことができます。
どのような登録ができるかというと、データベース、クエリ、セッション、ドキュメントなどになります。この変更通知を使って、データに対してどこで何が変わったかという情報がすぐ手に入ります。
これもソースコードを減らすことに繋がります。ライブクエリを作成し、ロジックを設定して終わりなのでとても簡単です。
Change Notifications: Objects in Couchbase lite, let you listen for changes/ observe for changes, using the standard or native change/ event notification system of your language of choice.
Multiple scopes for change notifications – we can listen for them at the database level, individual query level, replication/ sync session level, even down to specific documents.
It cuts down significantly on the amount of cruft code we have to write. All we do is create our live query and then provide the functional call back using the language specific notification system to drive UI updates. Once we’ve taught our application how to deal with changes in data, we can set it and walk away.
4つ目の特徴はマルチマスター同期です。
マルチマスターというのはマスター・マスターと違って複数のエンドポイントに同期ができます。Couchbase Liteにはマルチマスター同期が機能として入っています。
同期は継続的(つまり、データができるだけ早く変更されてから同期されます)かアドホック(つまり同期が終わった後にもう一回同期したい場合は手動的に行う必要がある)という2つの種類があります。同期は単方向(たんほうこう)、双方向(そうほうこう)のどちらの方向もできます。
継続的かアッドホックという選択があるメリットは電池の省エネができることです。モバイルデバイスの電池を一番消費するのは電波接続です。電波接続を少なく使うのがベストです。実は継続的に同期する必要がないアプリが多いです。たくさんのアプリは起動時に製品カタログを更新したり、終了時にログやアナリティクスを送信したりするような処理だけします。ユーザーか購入やリクエストをする際にアドホックの同期を行うのは可能です。そういったデータに関しましては継続的な同期の必要はなさそうです。自分のアプリのデータとその処理を考慮した上に決める方がよいでしょう。そして、前に紹介した変更通知と同様、情報が変わるとイベントが発生します。さらに、Gitなどのバージョン管理と同じMVCCを使っています。従って、競合が入って来ると自動的に解決するかアプリのロジックによって解決することができます。
Sync: a very simple mechanism in Couchbase Lite. Full multi-master replication (not master-master because you are not limited to only one end point, you can sync with N number of end points)
Sessions can be run either continuously (minimum latency in data changes between two systems) or ad-hoc, as soon as the sync session is done, then that’s it. Any further updates, you will have to run another sync session. Sync sessions can be done in either direction.
The nice thing about being able to had the choice between continuous and ad-hoc, we can be good about our end users battery life. The biggest drain on our mobile devices, our batteries, is the radio. You want to minimize the amount of radio usage our app requires. You want to make sure we are using the minimum for the use case that we have. Many applications don’t have a lot or any data that needs to be synced in real times. Many apps can pull at app start up to refresh a product catalogue (retail) or just do a one off push when they are closing, to push off logging or analytical data. As a user completes a purchase or individual request, there can be a one-off push sync. We don’t need to be in continuous push or pull mode for those types of data. You have to look at your application and the kind of data (speed and flows) you have and we can handle it responsibly with Couchbase lite.
We get our change in notifications, and we also get the ability through that mechanism to do conflict detection. Each document will provide a list of conflicting revisions, if there are any. Couchbase lite implements the same MVCC algorithm that Git uses and Mercurial, and most other distributed versioning systems use. If you’re familiar with how to use those tools, then you will be very comfortable with Couchbase lite. In Git for example, if you’ve got a branch, we call that a document, if you have a commit, we call that a revision. If you have two commits in conflict, many times they can be auto-merged, and in the cases you can’t, you simply make a merge-commit, just like you would in Git, except we would have a merge revision in that case. It’s very simple and easy to use.
こちらはCouchbaseがサポートしている言語とプラットフォームです。iOS (Swift / Objective-C両方)、Android、.NETとJavaの上にPhoneGapやXamarinやTitaniumの様なマルチプラットフォーム環境もサポートしております。
入手するにはCocoapods, Maven Central, Nuget, 並びにGitHubからソースもダウンロードすることが出来ます。それらによって開発者のプロジェクトに追加することを簡単にいたします。
These are the platforms and languages and environments we support. Any modern and popular operating system we provide support for, for Couchbase lite. We provide native implementations for iOS and also, we support Swift, Java, and .NET as well. We also support multi-platform programming environments like Phonegap, Xamarin, and Appcellerator’s Titanium.
You can get your hands on Couchbase Lite by Cocoapods, Maven Central, Nuget if you’re a .NET developer, or you can get the source from Github. We make it super easy to add to your project and to get started with.
続いて、Sync Gatewayについて話します。この図はSync Gateway内部の構造を表しています。
Sync GatewayはCouchbase Lite (ローカルデータベース)とCouchbase Server (NoSQLデータベース)の間で機能するアプリケーションです。
つまり、モバイルアプリとクラウドをつなぐ役割を担(にな)います。普通のウェブアプリケーションのように認証と権限付与を行うだけでなく、独自的にデータの扱いも行います。
様々なデバイスからデータを収集したり、許可されたユーザだけに書込み権限を与えたり、閲覧権利のないユーザのデバイスと同期しないなど、様々な定義の方法があります。
またTBもの大きなデータをモバイル端末に保存できない、またはしたくない場合、一部のデータだけ端末にもち、残りのデータをサーバから同期しない方法もSync Gatewayで設定することができます。
Let’s talk about Sync Gateway. Sync Gateway handles the boundary between your private data center and your public cloud. When I say private data center, that can still be in a public cloud like EC2 or Azure where you’ve got a number of VMs running. It handles the same cross cutting concerns from your application that you would have in any web-based application: things like Authentication, Authorization, and unique to Sync Gateway: it provides a method of data orchestration.
We often have all these streams of documents coming up from different devices, and we want to do things like ensure that writes are only allowed to documents where users have appropriate authorization and make sure that, if someone shouldn’t be able to see a document, that it doesn’t get replicated down to their device.
We also need to define relevancy, because we can’t possibly fit the entire application database of however many terabytes onto an individual phone. We need to only sync the information that user cares about, and we need a way to programmatically define what that user cares about. And that’s another thing that Sync Gateway does for you.
更に、Sync Gatewayはアプリのデータをクラウド、つまりCouchbase Serverに送って保存するという役割も行っています。デバイスがSync Gatewayに同期していると同時にSync GatewayがCouchbase Serverに書き込んでいます。
それでは、権限付与についてもう少し詳しく見てみましょう。
Sync gateway also handles the permanent persistence of your applications data in your Couchbase Server cluster that lives in your private data center. So as your device is syncing with sync gateway and pushing your data up, sync gateway is also writing that data into the permanent data store, backed by our highly scalable Couchbase Server technology.
Now, let’s look at security layer concerns: in this particular case, authorization.
今回はあまり時間がありませんのでCouchbase Serverの解説を割愛(かつあい)させて頂きましたが、簡単にCouchbase Serverについて触れたいと思います。
Couchbase Serverはドキュメント指向のNoSQLデータベースです。そのためCouchbaseモバイルソリューションではJSONドキュメントをモバイル端末とサーバ間で変換することなくやり取りができます。Couchbase Serverはデータの増減(ぞうげん)に併(あわ)せてスケールまたは縮退(しゅくたい)することが可能で、運用が非常に楽なデータベースです。Webの管理画面もついており、ワンクリックでノードの追加、削除、そしてデータのリバランスをすることができます。サービスを停止することなくオンラインでHDのメンテナンス、ソフトウェアのアップグレードを行うことができます。
When it comes to delivering scalability and availability with Couchbase, a number of architectural features come into play.
Built-in replication: Every server takes care of some active data and some replica data.
Cluster Map: The app server tier at the top includes the Couchbase Client Library -- which is similar to an SDK or JDBC driver in the relational world and includes the Cluster Map.
The Cluster Map is important, because that’s what makes it transparent to the application about where the data lives. The database takes care of how data gets distributed and where to access any specific piece of data. So all that complexity is removed from the app programming and pushed to the database.
So here for example, a data request from App Server 2 comes in, and the Cluster Map knows that data lives on Couchbase node 1 (and by the way is replicated to node N), so it retrieves the data on server 1 and returns it to the app -- completely transparent to the application and the developer. Couchbase takes care of all that magic, as well as the availability which is the replication aspect.
So these capabilities allow you to build highly scalable and available applications and remove a lot of the complexity that you face with relational databases.