Hacker News new | past | comments | ask | show | jobs | submit login

The current project I am working on has been developing an offline-first, messaging/calling app that started as a webapp but was decided to also have native apps for Android/iOS. But because the web app came first, the web-centered architecture was kept, and the javascript developers have chosen PouchDB/CouchDB as the single data storage/sync mechanism.

I was peripherally involved in the part of the services that dealt with user data - basically, massaging data from the address book and call history, dealing with the backend.

This is a collection of things I believe I can say after working on this for almost two years:

- PouchDB + CouchDB works well, as long as you are already used to model your application in terms of CouchApps. No SQL, no E-R representation of your data, etc. If you are not comfortable with the couchDB model and don't know your way around views, you are not going to have a good time.

- This is not an issue with PouchDB, but it if you are planning on having native apps, I'd strongly advise against. All of our native app developers struggled with the change in mindset and the not so mature state of couchbase for Android/iOS. And because they can use SQLite, forcing them to adopt couchbase was not but pain in our team.

- You need to figure out security and authentication: if you take the direct approach of using one couchdb per user and just replicate that, you need to figure out on your own how to secure access. CouchDB only supports OAuth 1 out of the box. We are using oAuth 2 for our services, and I basically had to implement a proxy server that checked oauth tokens before passing requests to our couchdb server.

- CouchDB that does not allow cross-database views, so if you take the "one-database-per-user" approach and you need to check anything that spans more than one database, you are on your own to create more databases/replicate/index/aggregate the data.

- The solution for sync helps, and continuous replication makes for a good demo, but it is not magic. Imagine if you have already accumulated some good amount of data in your database. The moment you start your application on a different browser, PouchDB will start desperately to sync everything you have. You need to know how filtered replication works.

- Very resource intensive, more so if you keep continuous replication. Constant usage of CPU and network I/O can make your app feel sluggish.




(PouchDB contributor here.) Just a quick note that slow replication is one of the things that is largely fixed in CouchDB 2.0 thanks to the new _bulk_get API (https://issues.apache.org/jira/browse/COUCHDB-2310) and is set to get even better in CouchDB 3.0 once it has HTTP 2.

As for your app feeling sluggish, my hunch is that you're seeing this in a Chromium or Gecko browser (e.g. Android WebView) in which cases IndexedDB does quite a lot of heavy operations on the UI thread (http://nolanlawson.com/2015/09/29/indexeddb-websql-localstor...), which can be mitigated by moving it to a Web Worker (as Pokedex.org does) or a Service Worker (as HospitalRun.io does).


Check out Cloudant Envoy to get around the "one-database-per-user" anti-pattern: https://github.com/cloudant-labs/envoy




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: