-
-
Save redjohn/1756659 to your computer and use it in GitHub Desktop.
| source :rubygems | |
| gem 'riak-client' |
| require 'json' | |
| [[:first, 2000, 9001], [:second, 50_000, 9002]].each do |record| | |
| urls = [] | |
| 1.upto record[1] do |i| | |
| url = { | |
| audit_id: record[2], | |
| url: "http://example.com/#{i.to_s(16)}", | |
| loadtime: 700 + rand(200), | |
| attempts: 1 + rand(3), | |
| objects: 1 + rand(300), | |
| processing_error: rand(1) == 1 ? true : false, | |
| status_code: [200, 301, 302, 404, 500].shuffle.first, | |
| depth: 1 + rand(4), | |
| } | |
| urls << url | |
| end | |
| File.open("#{record[0]}.json", 'w') {|f| f.write(urls.to_json) } | |
| end |
| require 'riak' | |
| client = Riak::Client.new(nodes: [{ host: 'localhost', http_port: 8091 }]) | |
| bucket = client.bucket('urls') | |
| bucket.n_value = 1 | |
| audits = [] | |
| [[:first, 9001], [:second, 9002]].each do |record| | |
| urls = JSON.parse(File.read("#{record[0]}.json")) | |
| audit_id = record[1] | |
| urls.each do |url| | |
| obj = bucket.new | |
| obj.data = url | |
| obj.indexes = { 'audit_id_int' => Set.new([audit_id]) } | |
| obj.store | |
| end | |
| end |
| { | |
| "inputs": { | |
| "bucket": "urls", | |
| "index": "audit_id_int", | |
| "key": 9001 | |
| }, | |
| "query": [ | |
| { | |
| "map": { | |
| "language": "javascript", | |
| "name": "Riak.mapValuesJson", | |
| } | |
| }, | |
| { | |
| "reduce": { | |
| "language": "javascript", | |
| "source": "function(values) { | |
| return values.map(function(item) { | |
| return (parseInt(item, 10) || item === 0) ? item : item.loadtime; | |
| }); | |
| }", | |
| } | |
| } | |
| ], | |
| "timeout": 120000 | |
| } |
I've duplicated your experiences, now we just need to find out why there is a timeout.
$ time curl -X POST localhost:8098/mapred -d @query.js[716,841,723,792,801,791,868,802,739,822,762,857,770,827,895,784,832,848,771,779,853,866,754,753,803,782,854,818,811,883,726,828,872,882,857,873,742,801,871,897,855,818,817,881,897,887,784,702,744,796,767,835,843,741,813,727,829,786,716,704,895,739,868,892,840,780,828,740,744,784,891,740,815,717,780,853,729,755,723,842,720,843,821,712,743,755,726,787,757,886,842,869,781,786,755,755,782,705,845,759,865,700,896,816,777,786,794,714,709,722,853,705,781,723,709,873,781,700,858,715,765,804,758,820,881,780,869,801,825,872,887,765,792,825,792,724,777,733,723,766,854,810,874,838,705,816,794,755,798,843,722,874,894,859,882,831,727,884,765,713,713,712,827,720,800,775,796,849,830,839,842,760,873,815,791,791,729,875,837,791,754,788,793,891,717,732,824,738,766,757,884,796,714,739,702,781,793,843,874,803,800,898,855,729,725,737,751,858,809,766,872,870,834,875,718,850,713,721,826,867,758,710,801,728,847,862,745,762,754,723,875,796,865,888,769,739,733,858,799,728,763,730,898,752,808,702,777,784,760,835,737,755,783,758,743,844,768,724,812,800,788,793,736,851,879,701,785,844,743,802,809,705,796,847,869,864,771,886,854,732,765,763,799,721,779,779,731,722,842,873,872,741,751,761,838,862,849,764,776,856,819,750,744,887,751,746,784,700,728,870,842,726,785,843,862,804,762,856,739,897,719,810,805,885,858,782,834,892,784,766,777,887,806,737,807,832,843,833,789,775,753,762,895,727,729,860,703,896,812,763,762,875,730,787,894,893,892,760,732,718,805,766,787,736,819,878,716,805,747,824,814,826,788,708,722,752,826,785,819,702,749,831,746,726,707,720,878,815,780,849,740,714,758,754,888,783,705,837,833,869,767,816,828,873,753,773,829,866,751,706,894,870,815,855,775,710,844,853,754,721,897,755,736,714,768,754,831,733,762,751,851,815,825,743,762,753,709,821,720,863,861,740,873,854,725,830,795,882,888,728,771,897,859,845,873,823,707,763,781,772,799,784,741,759,718,756,727,852,759,744,813,894,819,859,720,820,804,865,893,896,793,804,895,893,887,825,811,835,780,767,805,880,875,708,881,826,705,828,775,807,774,853,855,780,853,710,813,761,842,839,856,773,877,703,720,751,786,796,779,811,862,898,853,754,843,744,886,755,804,841,709,856,765,818,856,884,766,728,820,731,817,857,780,865,782,835,894,875,731,857,856,752,787,894,725,796,775,760,815,784,840,864,858,741,750,852,829,890,778,858,714,884,702,811,847,891,718,830,855,718,833,861,789,717,726,801,809,856,718,858,743,841,831,884,860,875,708,804,730,765,742,796,798,865,874,785,759,713,804,887,807,724,841,785,754,758,762,733,730,718,838,731,832,872,826,746,868,813,891,762,726,739,825,854,753,877,782,763,853,727,730,843,846,728,796,867,826,859,759,729,870,774,839,782,751,766,706,766,728,848,711,713,882,874,850,866,841,863,731,734,800,883,766,856,837,882,864,878,757,720,734,805,807,784,888,780,770,727,871,848,710,751,731,722,790,758,784,762,824,730,759,870,847,714,823,844,719,842,806,811,808,791,840,744,846,828,776,701,769,718,866,714,755,865,701,871,786,729,767,890,786,851,852,874,760,791,751,756,844,713,807,886,894,801,824,713,709,723,877,798,831,728,882,771,795,840,837,766,810,756,872,785,888,810,746,754,714,767,712,895,783,819,752,894,728,797,813,719,808,754,719,816,766,744,801,875,873,897,818,711,822,739,883,815,808,813,703,723,710,756,868,863,765,840,880,765,845,731,810,805,886,884,779,760,803,780,871,713,802,732,754,835,893,803,799,834,826,894,867,728,839,743,719,878,819,838,715,806,843,750,770,728,750,772,817,815,848,748,897,815,805,720,716,833,815,749,859,764,814,795,774,734,700,805,764,834,769,736,704,887,885,872,817,821,794,706,703,871,715,809,896,737,712,760,878,789,875,705,890,898,721,758,802,814,825,738,854,835,782,897,751,874,778,887,834,718,861,875,786,740,838,737,714,897,779,805,794,832,765,734,873,800,735,768,825,752,801,727,839,847,815,772,779,831,764,773,867,736,848,844,806,711,702,795,750,750,789,831,797,781,781,872,878,836,858,797,742,886,816,858,784,885,861,820,723,775,767,867,816,851,812,709,880,877,843,863,807,869,784,835,741,718,737,701,798,727,850,858,766,890,801,781,710,729,768,723,856,879,721,796,782,806,806,819,752,728,718,704,858,897,787,808,820,822,842,886,807,885,750,735,767,798,716,769,721,775,819,856,795,800,810,817,815,877,859,894,846,869,774,730,754,845,756,895,759,849,752,776,791,871,765,749,764,869,854,875,838,720,727,737,748,783,703,830,712,712,701,708,818,748,773,809,771,864,746,799,715,800,898,826,881,838,840,726,878,850,782,744,706,735,813,890,707,720,823,740,725,831,712,854,734,853,867,817,815,829,885,735,870,848,858,857,711,777,864,751,803,807,737,742,862,753,762,794,896,800,896,845,790,772,749,826,894,715,788,800,872,817,883,762,888,882,855,837,806,719,849,743,756,759,714,873,778,881,791,843,724,844,848,822,774,897,861,841,765,739,799,818,731,826,798,896,702,762,836,740,854,768,790,747,854,752,754,865,705,776,768,790,702,898,861,846,869,886,741,781,715,730,772,759,725,838,777,729,898,710,700,706,876,875,874,815,741,822,833,802,784,849,745,793,710,744,729,749,804,886,898,818,824,707,887,824,763,718,798,704,735,725,809,849,842,894,710,888,765,777,874,879,739,844,726,786,756,714,713,712,799,855,865,728,789,736,884,848,839,777,769,853,851,821,807,874,729,800,891,898,822,893,773,809,714,791,846,731,858,897,886,807,730,836,743,756,756,710,743,810,890,853,715,884,892,847,891,796,701,834,782,821,896,896,730,897,894,819,818,831,756,704,812,714,754,718,775,865,801,829,769,710,841,707,742,859,744,721,859,896,788,893,836,726,757,766,794,734,784,733,775,818,877,767,895,789,751,860,736,861,887,878,737,872,832,859,796,894,828,828,899,784,830,785,759,803,701,823,766,892,804,707,727,811,815,813,762,862,807,848,832,839,878,827,709,793,850,856,860,788,855,875,763,879,892,893,701,758,724,814,798,700,739,715,760,708,718,712,837,706,893,800,767,835,824,850,711,815,837,718,857,836,878,795,855,798,887,813,897,843,787,828,724,859,816,834,824,823,775,738,710,767,788,740,779,825,880,812,839,784,703,725,824,763,708,802,739,729,735,717,738,736,824,784,812,884,732,717,820,716,702,888,703,768,897,866,890,878,759,760,710,725,778,860,884,834,797,800,859,854,794,789,772,860,727,802,772,803,806,722,769,745,772,760,848,700,882,887,897,754,823,766,777,786,866,730,853,730,895,889,876,868,782,889,820,830,839,826,769,751,726,881,763,882,753,737,736,859,892,885,811,764,720,866,860,708,814,778,769,881,770,771,881,813,856,738,741,820,705,747,828,868,886,850,857,843,845,883,870,798,862,810,713,835,813,792,869,753,812,802,822,734,862,705,874,764,815,837,708,722,827,767,783,703,864,822,758,804,739,807,824,755,786,741,751,740,813,796,820,826,875,885,843,864,792,808,862,838,762,764,879,829,832,869,839,768,725,810,896,765,702,847,771,728,805,783,836,718,782,783,792,743,827,822,720,708,701,843,893,873,872,774,864,791,856,895,759,728,859,808,791,872,721,773,767,868,760,817,749,864,855,818,701,881,811,758,711,849,748,721,802,738,800,837,734,757,831,762,721,827,727,738,895,717,813,833,720,775,734,757,740,760,767,804,831,801,786,818,860,834,819,816,768,752,840,745,864,861,721,897,740,732,718,768,849,802,747,756,785,742,867,772,734,739,893,719,894,717,815,734,754,878,777,735,899,703,860,757,817,737,725,892,700,754,897,859,801,887,736,707,720,873,724,730,871,828,800,898,757,748,889,804,757,896,816,899,894,841,853,773,803,777,778,870,786,815,717,766,770,855,876,752,712,820,878,851,765,876,744,839,705,868,776,762,821,892,881,854,860,799,818,745,869,828,817,755,826,770,873,886,852,737,878,896,805,833,826,865,814,812,886,703,791,727,851,892,736,780,870,743,891,855,717,749,763,730,845,788,845,884,724,756,767,722,802,856,851,864,846,753,798,704,896,881,835,789,840,818,846,839,768,810,781,861,875,747,799,879,802,797,822,813,824,853,849,864,783,765,735,873,715,827,808,739,827,779,732,725,800,791,872,767,777,841,783,745,730,755,827,840,887,888,829,852,707,758,743,739,880,734,800,793,732,780,839,709,803,783,813,873,754,783,876,793,784,732,892,751,722,847,708,825,847,795,817,810,848,827,859,843,759,829,822,716,865,777,710,899,772,730,888,783,840,746,853,823,877,704,806,897,812,778,829,712,780,700,874,743,865,743,863,891,797,825,705,762,722,884,803,762,853,766,727,732]
real 0m2.568s
user 0m0.009s
sys 0m0.005s
$ time curl -X POST localhost:8098/mapred -d @query.js{"error":"timeout"}
real 2m0.030s
user 0m0.007s
sys 0m0.006s
s/9001/9002/ in query.js and re-run query: