Skip to content

Instantly share code, notes, and snippets.

@simong
simong / gist:6052194
Last active December 20, 2015 01:49

Push notifications

Problem definition

Notifications should be pushed out to clients (over websockets via socket.io) whenever an activity occurs that might interest them. The activities need to be routed from the activity servers (as they generate them) to the app servers who will then take care of delivering it too the clients.

Server setup

@simong
simong / gist:6121056
Created July 31, 2013 10:42
tsung websocket xml
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/opt/local/share/tsung/tsung-1.0.dtd" []>
<tsung loglevel="notice" version="1.0" dumptraffic="true">
<!-- Each client that will be running Tsung during the test -->
<clients>
<client host="localhost" use_controller_vm="true" maxusers="1000" />
</clients>
<!-- Each remote server that Tsung should performance test against. Only one would be needed if you have a load balancer. -->
@simong
simong / tsung.xml
Created July 31, 2013 13:24
A tsung XML file to benchmark Socket.IO servers.
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/opt/local/share/tsung/tsung-1.0.dtd" []>
<tsung loglevel="notice" version="1.0" dumptraffic="true">
<!-- Each client that will be running Tsung during the test -->
<clients>
<client host="localhost" use_controller_vm="true" maxusers="1000" />
</clients>
<!-- Each remote server that Tsung should performance test against. Only one would be needed if you have a load balancer. -->
var fs = require('fs');
fs.readFile('scripts/users/0.txt', function(err, users) {
users = users.toString().split('\n');
users.forEach(function(user) {
user = JSON.parse(user);
console.log('%s - %s', user.userid, user.password);
});
});
var https = require('https');
var url = require('url');
//var endpoint = 'https://oae.gatech.edu';
var endpoint = 'https://www.incommon.org';
var options = url.parse(endpoint);
options.method = 'GET';
https.get(options, function() {
[root@37.153.104.210] out: Notice: /File[/var/lib/puppet/lib/puppet/parser/functions/strftime.rb]/ensure: defined content as '{md5}e02e01a598ca5d7d6eee0ba22440304a'
[root@37.153.104.210] out: Notice: /File[/var/lib/puppet/lib/puppet/parser/functions/chop.rb]/ensure: defined content as '{md5}4691a56e6064b792ed4575e4ad3f3d20'
[root@37.153.104.210] out: Notice: /File[/var/lib/puppet/lib/puppet/util/firewall.rb]/ensure: defined content as '{md5}071f574f08906d80b39fe0d1ddc14edf'
[root@37.153.104.210] out: Notice: /File[/var/lib/puppet/lib/puppet/parser/functions/is_float.rb]/ensure: defined content as '{md5}f1b0d333061d31bf0c25bd4c33dc134b'
[root@37.153.104.210] out: Notice: /File[/var/lib/puppet/lib/puppet/parser/functions/parsejson.rb]/ensure: defined content as '{md5}e7f968c34928107b84cd0860daf50ab1'
[root@37.153.104.210] out: Notice: /File[/var/lib/puppet/lib/puppet/parser/functions/validate_cmd.rb]/ensure: defined content as '{md5}0319a15d24fd077ebabc2f79969f6ab5'
[root@37.153.104.210] out: Notice: /File[/var
cqlsh:oae> SELECT * FROM "AuthenticationLoginId" WHERE "loginId" = 'admin:local:administrator';
Request did not complete within rpc_timeout.
Tracing session: 7a96d380-5772-11e3-a8d6-43b9fc51e529
activity | timestamp | source | source_elapsed
----------------------------------------------------------------------------------------------------------+--------------+--------------+----------------
execute_cql3_query | 14:44:54,584 | 10.224.16.81 | 0
Parsing SELECT * FROM "AuthenticationLoginId" WHERE "loginId" = 'admin:local:administrator' LIMIT 10000; | 14:44:54,584 | 10.224.16.81 | 118
Preparing statement | 14:44:54,584 | 10.224.16.81 | 293

Cassandra data model

Publications

Contains the publication metadata necessary to generate pretty lists

publicationId displayName type date thumbnailUri publisher linkedContentId
p:abc123 Origin of Species book 123456789 remote:http//... Cambridge null
p:def456 SSTables in practice article 12345789 null NoSQL in the real world c:cam:kljs2341
$.ajax({
'type': 'POST',
'url': '/api/content/reprocessPreviews',
'data': {
'revision_mime': [
'application/msword',
'application/rdf+xml',
'application/vnd.ms-excel',
'application/vnd.ms-powerpoint',
'application/vnd.oasis.opendocument.presentation',
<html>
<body>
<table>
<thead>
<th>Name</th>
<th>B</th>
<th>20</th>
<th>19</th>
<th>18</th>
<th>17</th>