28. Store results on Dynamo DB
Kinesis
Stream
Twitter4J Kinesis MeCab Dynamo Unity
private static PutItemRequest createPutItemRequest(String id, String datetime, String name,
String screenName, String text, Double value) {
Map<String, AttributeValue> putItems = new HashMap<String, AttributeValue>();
putItems.put("AppName", new
AttributeValue().withS(PropUtil.getInstance().getProp("ApplicationName")));
putItems.put("Datetime/SerialNumber", new AttributeValue().withS(datetime+"/"+id));
putItems.put("ScreenName", new AttributeValue().withS("@" + screenName));
putItems.put("Name", new AttributeValue().withS(name));
putItems.put("Text", new AttributeValue().withS(text));
putItems.put("Value", new AttributeValue().withN(Double.toString(value)));
PutItemRequest putItemRequest = new
PutItemRequest().withTableName(PropUtil.getInstance().getProp("DynamoDbTableNameDetail")).withIte
m(putItems);
return putItemRequest;
}
48. Inside story
I monitored processes of my program in server-side
because I had to accomplish this real-time demonstration
within 5 min.
But an incident happened.
Just before my turn to go on stage,
I noticed that a process which retrieve POWER’s data from
Dynamo DB was often stopped.
ec2-user 14685 0.1 4.2 1625848 71584 ? Sl 02:10 0:27 java KinesisPutter
ec2-user 18622 2.2 4.8 1787796 82660 pts/1 Sl 06:01 0:21 java -Djava.library.path=.:/usr/local/bin/mecab-java KinesisGetter
ec2-user 18944 22.0 4.2 1618412 71836 ? Sl 06:16 0:08 java DynamoJsonCreator
↓
ec2-user 14685 0.1 4.2 1625848 71584 ? Sl 02:10 0:27 java KinesisPutter
ec2-user 18622 2.2 4.9 1839496 83452 pts/1 Sl 06:01 0:21 java -Djava.library.path=.:/usr/local/bin/mecab-java KinesisGetter
49. Inside story
I tried to set an alive-monitoring by “cron” and be able to
restart a process automatically when it’s dead.
crontab -l
*/2 * * * * bash /home/ec2-user/KinesisTwitter/check_putter.sh > /home/ec2-user/cron.log.putter.txt 2>&1
*/2 * * * * bash /home/ec2-user/KinesisTwitter/check_getter.sh > /home/ec2-user/cron.log.getter.txt 2>&1
*/2 * * * * bash /home/ec2-user/KinesisTwitter/check_create_json.sh > /home/ec2-user/cron.log.create.json.txt 2>&1
In the meantime,
I found my mistake that Dynamo DB’s throughput set 1.
(;´Д`) oh…
50. Inside story
Nintendo’s presentation had started and the frequency of
#jawsdays’s tweet was increasing. Then my program’s
process was stopped.
I modified Dynamo DB’s throughput to solve a problem.
This is the quintessence of AWS.
Nintendo’s presentation
start
Modify throughput