You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: getting-started-with-firebase-2019-edition/getting-started-with-firebase-2019-edition.md
+68-9Lines changed: 68 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Firebase enables a distributed architecture.
28
28
29
29
New developers have traditionally learned to build monolithic apps.
30
30
31
-
A monolith is a single application server that holds your database and server. Everything lives on a single server that you control, so it's very easy to teach and understand.
31
+
A monolith is a single application server that holds your database and server. Everything lives on a single server that you control, so it's very easy to teach and understand.
32
32
33
33
The first managed service that I used was Amazon S3. It was an endpoint where I could send files. S3 would save the files and give me a link. I'd save the link in my local SQL database and S3 would serve the file to my users.
34
34
@@ -64,7 +64,7 @@ So get over your SQL-induced anxiety and duplicate data throughout your Firebase
64
64
65
65
## The Evil Twin Databases
66
66
67
-
Firebase now has two databases,
67
+
Firebase now has two databases,
68
68
69
69
1. the [Realtime Database](https://firebase.google.com/docs/database/), also known as classic Firebase or the RTDB, and
@@ -96,36 +96,95 @@ The other projects took between 75 and 200 hours each. Again, I finished them in
96
96
97
97
Firebase has spoiled me. I haven't spun up a new production server in two years. And these aren't just rapid prototypes. They're fully-functional, scalable and used by thousands of customers.
98
98
99
-
## Firebase includes *nearly* everything I need to build small- to medium-sized apps
99
+
## Firebase includes _nearly_ everything I need to build small- to medium-sized apps
100
100
101
-
The pillars of Firebase's web offering are
101
+
The pillars of Firebase's web offering are
102
102
103
103
- the Realtime Database (json database),
104
104
- Cloud Firestore (document/collection database),
105
105
- Cloud Functions for Firebase (serverless functions),
106
-
- Firebase Storage (file/blob storage), and
106
+
- Firebase Storage (file/blob storage), and
107
107
- Firebase Hosting (static file hosting).
108
108
109
109
These five pillars can support an enormous range of apps.
110
110
111
-
Realistically, you'll need to "cheat" on Firebase a bit for larger apps. I use GCP for a few things that don't fit neatly within the Firebase offering. I also use [Algolia](https://www.algolia.com/) to power my search.
111
+
Realistically, you'll need to "cheat" on Firebase a bit for larger apps. I use GCP for a few things that don't fit neatly within the Firebase offering. I also use [Algolia](https://www.algolia.com/) to power my search.
112
112
113
-
The funny thing is that Algolia is the most expensive part of my stack at $35/month. The Firebase databases are optimized for everything **except search**. This is an important caveat to recognize early. Searching Firestore collections or anything in the Realtime Database is extremely limited, and for strong architectural reasons. I don't expect to ever see Firebase support search.
113
+
The funny thing is that Algolia is the most expensive part of my stack at \$35/month. The Firebase databases are optimized for everything **except search**. This is an important caveat to recognize early. Searching Firestore collections or anything in the Realtime Database is extremely limited, and for strong architectural reasons. I don't expect to ever see Firebase support search.
114
114
115
-
I primarily use GCP to manage the DNS for my domains. But I've also run some Cloud Compute instances for build processes.
115
+
I primarily use GCP to manage the DNS for my domains. But I've also run some Cloud Compute instances for build processes.
116
116
117
117
And I use [GitLab.com](https://gitlab.com/deltaepsilon) for CI/CD purposes... so I guess I step out on Firebase a couple of times on each project :)
118
118
119
119
## Firebase scales effortlessly
120
120
121
+
Firebase does not allow slow operations. The database does not execute joins. It doesn't search.
121
122
123
+
I've never brought a Firebase app up to massive scale. I've heard that the Realtime Database can run into limits and require manual sharding; however, Firestore is architected much differently, and I wouldn't be surprised if it scales more like [Cloud Spanner](https://cloud.google.com/spanner/).
124
+
125
+
Firestore has some awesome performance characteristics.
126
+
127
+
From the [Firestore marketing page](https://firebase.google.com/products/firestore/):
128
+
129
+
> All queries scale with the size of your result set (note: not your data set), so your app is ready to scale from day one.
130
+
131
+
Firestore also offers strong consistency, meaning that you don't have to worry about the eventual-consistency data models that bedevil most NoSQL implementations.
122
132
123
133
## GCP is the escape hatch
124
134
135
+
Firebase services are built on Google Cloud Platform (aka GCP) infrastructure, and some of them are closely integrated.
136
+
137
+
For instance, Firebase Cloud Storage uses GCP Storage buckets that you can access through the GCP SDKs.
138
+
139
+
GCP is an enterprise-focused suite of service. It's massive.
140
+
141
+
Each Firebase project comes with its own GCP account, granting you access to the full power of GCP. So don't worry if Firebase doesn't fulfill your every need. GCP likely has it covered.
142
+
143
+
For example, If you don't want to pay for Algolia, you can spin up an Elasticsearch cluster on GCP and roll your own search. It'll be just as expensive as Algolia... so I can't recommend it for small projects; however, those capabilities are all there if you need them.
144
+
125
145
## Common concerns with Firebase
126
146
147
+
Firebase has it's downsides!
148
+
149
+
- Firebase cannot be hosted locally.
150
+
- Firebase is tough to mock for local unit tests.
151
+
- There's far less tooling available than for SQL databases.
152
+
- Firebase can get expensive if you implement it poorly.
153
+
154
+
None of these problems bothers me. It may be Stockholm Syndrome... but I'm at peace with all of these "problems" with Firebase.
155
+
156
+
Engineering is all about tradeoffs. Firebase trades a bunch of control and autonomy for speed and simplicity of development.
157
+
127
158
## When to NOT use Firebase
128
159
160
+
**DO NOT** use Firebase if you have highly relational data.
161
+
162
+
**DO NOT** use Firebase if you have complex graph data.
163
+
164
+
**DO NOT** use Firebase if you have complex server needs.
165
+
166
+
I sometimes recommend hybrid architectures. Store your relational data in GCP's Cloud SQL or Cloud Spanner databases. Store your graph data in JanusGraph on top of Cloud Bigtable.
167
+
168
+
But these are all advanced use cases! Don't worry about them until you need them.
169
+
129
170
## The competition
130
171
131
-
## Conclusion: Firebase is preferred for most front-end-focused apps
172
+
Firebase's direct competition is dead. [Facebook killed off Parse](https://blog.parseplatform.org/announcements/a-parse-shutdown-reminder/) and [RethinkDB](https://rethinkdb.com/blog/rethinkdb-shutdown/) suffered a similar fate.
173
+
174
+
The most direct alternative to Firebase at this point is AWS or GCP. They're quite a bit more complicated and harder to use... but you could achieve similar architectures with other services.
175
+
176
+
Or just use Postgres. Postgres is killer... as long as you have budget to write your own API on top of it.
177
+
178
+
That's about it. Use AWS, GCP or Postgres. Your dev velocity will suffer, but at least with Postgres you can run everything locally!
179
+
180
+
I've spent a lot of time with Postgres running in a local Docker container, and it's slick. I didn't write that API myself. It was expensive to maintain, and I could have duplicated it in Firebase at a much lower cost. But the business I was working with wasn't a fan of managed services. What could I do :)
181
+
182
+
## Conclusion: Firebase is preferred for most front-end-focused apps
183
+
184
+
Firebase is a slam dunk for small- to medium-sized projects, especially if they're front-end focused.
185
+
186
+
You may need to re-architect if you hit massive scale... but you **always** have to re-architect for massive scale. Don't optimize for scale prematurely.
187
+
188
+
Choose Firebase because it gets you to market faster. It helps you validate your ideas and get feedback.
189
+
190
+
Firebase is a cornerstone of Google's cloud strategy. It's not going anywhere.
0 commit comments