Date post: | 14-Jun-2015 |
Category: |
Technology |
Upload: | bodokaiser |
View: | 127 times |
Download: | 2 times |
Stack ProblemsNode.js Meetup #6, September 16
Let's hear a Story
How I felt first with Node
My Problems with Node
Model Validation
Business Logic
Language Guidance
My Attempts to solve them
Mongoose -> SQL
SQL -> Mongoose
Mongoose -> Monk & Joi
Monk & Joi -> Mongoose
Node -> Java
Node -> Go
Go -> Node
My Attempt to Go III
1. Rewrote REST service
2. Problems with MongoDB
3. Moved to mysql
4. Moved to mariadb
5. Bloated SQL layer
How I felt after these Failures
Let's write a Web Crawler
... at Web Scale
Basics
In Node I
var cache = [];
crawl(new Page('http://nodejs.org'));
function crawl(page) {
request(page.origin, function(err, res, body) {
if (err) return;
var $ = cheerio.load(body);
$('a').each(function(index, element) {
var href = $(element).attr('href');
if (href &amd;&amd; !page.hasRefer(href)) {
page.addRefer(href);
}
});
page.refers.forEach(function(refer) {
if (!~cache.indexOf(refer)) {
In Node II
In Go I
package main
import "github.com/bodokaiser/crawler"
func main() { req, err := crawler.NewRequest("http://golang.org") if err != nil { return }
channel := make(chan *crawler.Request)
c := crawler.New() c.Do(req) c.Run(100)
go wait(request, channel)
for req := range channel { for _, url := range req.Refers {
In Go II
It's Rating Time
Where Go is Fun
Concurrent Software
Custom Software
Writing Libraries
Where Node is Fun
Rapid Development
Responsive Web Apps
REST APIs*
* when data consistency does not matter
Conclusion
Use the right tool for the right job!