+ All Categories
Home > Technology > Stack problems

Stack problems

Date post: 14-Jun-2015
Category:
Upload: bodokaiser
View: 127 times
Download: 2 times
Share this document with a friend
Description:
Node.js and Google Go and a lot of problems regarding which stack to choose which ended up in some web crawler action :)
Popular Tags:
18
Stack Problems Node.js Meetup #6, September 16
Transcript
Page 1: Stack problems

Stack ProblemsNode.js Meetup #6, September 16

Page 2: Stack problems

Let's hear a Story

Page 3: Stack problems

How I felt first with Node

Page 4: Stack problems

My Problems with Node

Model Validation

Business Logic

Language Guidance

Page 5: Stack problems

My Attempts to solve them

Mongoose -> SQL

SQL -> Mongoose

Mongoose -> Monk & Joi

Monk & Joi -> Mongoose

Node -> Java

Node -> Go

Go -> Node

Page 6: Stack problems

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

Page 7: Stack problems

How I felt after these Failures

Page 8: Stack problems

Let's write a Web Crawler

Page 9: Stack problems

... at Web Scale

Page 10: Stack problems

Basics

Page 11: Stack problems

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)) {

Page 12: Stack problems

In Node II

Page 13: Stack problems

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 {

Page 14: Stack problems

In Go II

Page 15: Stack problems

It's Rating Time

Page 16: Stack problems

Where Go is Fun

Concurrent Software

Custom Software

Writing Libraries

Page 17: Stack problems

Where Node is Fun

Rapid Development

Responsive Web Apps

REST APIs*

* when data consistency does not matter

Page 18: Stack problems

Conclusion

Use the right tool for the right job!


Recommended