How Node, Express and Postgres and help meet the challenges of building a scalable Web Service.
Node is event-oriented and able to take high load.
Express makes your code very simple and maintainable. Supports API-styled web service.
Postgres supports your data needs with a very flexible data structure.
2. ABOUT ME.
• Programming as a hobby.
• Final student, NTU (Biz IT).
• Mainly involved in tech-related
entrepreneurial projects.
• Latest project is
VogueVerve.com.
5. WHAT IS NODEJS?
• It is a server side Javascript
runtime environment.
• Powered by Chrome V8.
• Main intention of real-time
communication.
• It can be a standalone server.
9. USING JS FOR SERVER-SIDE
APPLICATION SOUNDED LIKE
A BAD IDEA.
Search “Node.js is cancer”
10.
11. HOW TO NODE?
• Delegate computationally
intensive tasks to lower-level
languages like C++.
• Make clusters (to combat
single-threading).
• Node errors will crash the
server. Gotta catch ‘em all.
23. HOW TO USE IT?
• Documentation is abit skimpy
and untelling.
• Learn by example:
https://scotch.io/tutorials/easy-
node-authentication-setup-
and-local
41. THE PROBLEM
• What if Joe
changes
name?
• What if a
new field is
added to
users?
42. YOU MAY REACH A POINT
WHERE THERE IS JUST TOO
MUCH TO REPLICATE.
43. YOU CAN DO THIS AND IT IS
STILL PROBABLY FAST
You find yourself trying to do “joining”.
Are there any ORMs for
Mongo/Couchbase?
44. CHANGE IS THE ROOT OF ALL
PROBLEMS.
Will your data become more relational
than it is now?
http://www.sarahmei.com/blog/2013/11
/11/why-you-should-never-use-
mongodb/
45. POSTGRES JSON AND
HSTORE
• A field that can contain “array-
structured” data.
• Atomic operations: Key/values
can be searched for and
indexed.
• Fast.
• Best thing since NPM, and
beer.
46. A VERY FLEXIBLE
STRUCTURE
id name data
1 Mary { “country”: “Singapore”, “dataMeta”: { “following”: “299”, “followers”:
“484” }}
2 Lucy { “country”: “France”}
3 Jane null
4 Tom {“dataMeta”: { “following”: “479” }}
5 Dick {“dataMeta”: { “following”: “12”, followers: “40”}}
50. IT IS NOT PERFECT
• Only HSTORE supports atomic
updates, JSON does not.
• HSTORE does not support
nested structure.
• Postgres JSON is very new.
Library support is adequate
but not mature.
52. CONCLUSION ON PG
• It is a RDB that is very capable
of handling schemaless data.
• Don’t over-normalize your
data.
• Use relations and constraints
for critical portions of your
data.