Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>Load balancing</h2> <p>Most probably for the most simple sites you don't need any scaling at all. Just one single box will get you covered. After that you should do load balancing like you are mentioning which is almost the same for every architecture(like you are saying you could start multiple node processes first. But when you get really big you need more boxes).</p> <p><a href="https://www.nginx.com/resources/wiki/start/topics/examples/loadbalanceexample/" rel="nofollow noreferrer">Nginx load balancing example</a>:</p> <pre><code>http { upstream myproject { server 127.0.0.1:8000 weight=3; server 127.0.0.1:8001; server 127.0.0.1:8002; server 127.0.0.1:8003; } server { listen 80; server_name www.domain.com; location / { proxy_pass http://myproject; } } } </code></pre> <h2>Redis</h2> <blockquote> <p>20 queries per second</p> </blockquote> <p>No sweat for node.js. You should use redis as your datastore because it is insane fast :). There is even a c library for node when you use <a href="https://github.com/mranney/node_redis" rel="nofollow noreferrer">node_redis</a>.</p> <pre><code>npm install hiredis redis </code></pre> <p>Hiredis is what gives you kickass performance because it compiles to C code inside node. Here are some benchmarks from redis when used with hiredis.</p> <pre><code>PING: 20000 ops 46189.38 ops/sec 1/4/1.082 SET: 20000 ops 41237.11 ops/sec 0/6/1.210 GET: 20000 ops 39682.54 ops/sec 1/7/1.257 INCR: 20000 ops 40080.16 ops/sec 0/8/1.242 LPUSH: 20000 ops 41152.26 ops/sec 0/3/1.212 LRANGE (10 elements): 20000 ops 36563.07 ops/sec 1/8/1.363 LRANGE (100 elements): 20000 ops 21834.06 ops/sec 0/9/2.287 </code></pre> <p>When you look at those numbers then 20/s is <strong>NOTHING</strong> :).</p> <h2>Authentication</h2> <hr> <p><strong>Update:</strong></p> <ul> <li><p><a href="https://github.com/bnoguchi/everyauth" rel="nofollow noreferrer">everyauth</a></p></li> <li><p><a href="https://github.com/havard/node-openid" rel="nofollow noreferrer">openid</a></p></li> </ul> <hr> <p>I am telling this a lot but for the love of god please don't try to implement your own authentication-system. It is probably going to be unsafe(a lot can go wrong), a lot of work. For authentication you should use facebook-connect, twitter single sign-in, etc using the excellent <a href="https://github.com/ciaranj/connect-auth" rel="nofollow noreferrer">connect-auth</a> library. Then you are covered safe because they have experts testing there login-systems for holes and the also don't transmit passwords via plain-text but thank for god use https. I also have answered a topic for a user who wanted to use <a href="https://stackoverflow.com/questions/4484825/what-is-the-best-facebook-connect-library-for-node-js/4485300#4485300">facebook-connect</a>.</p> <h2>validation of input data</h2> <p>To validate input you could use <a href="https://github.com/chriso/node-validator" rel="nofollow noreferrer">node-validator</a>. </p> <pre><code>var check = require('validator').check, sanitize = require('validator').sanitize //Validate check('test@email.com').len(6, 64).isEmail(); //Methods are chainable check('abc').isInt(); //Throws 'Invalid integer' check('abc', 'Please enter a number').isInt(); //Throws 'Please enter a number' check('abcdefghijklmnopzrtsuvqxyz').is(/^[a-z]+$/); //Sanitize / Filter var int = sanitize('0123').toInt(); //123 var bool = sanitize('true').toBoolean(); //true var str = sanitize(' \s\t\r hello \n').trim(); //'hello' var str = sanitize('aaaaaaaaab').ltrim('a'); //'b' var str = sanitize(large_input_str).xss(); var str = sanitize('&amp;lt;a&amp;gt;').entityDecode(); //'&lt;a&gt;' </code></pre> <p>There also is this <a href="https://github.com/caolan/forms" rel="nofollow noreferrer">forms</a> library to help you create forms.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload