Monday, November 2, 2020

AWS Quicksight

 与Tableau和SSIS类似,用于生成BI report。


report的参数

先产生一个paramter和对应的filter,然后就可以在report的URL加入如下,jobId是parameter name























https://us-west-2.quicksight.aws.amazon.com/sn/dashboards/e0176d07-f509#p.jobId=1568446


用户互动输入filter

原理同上,不过再加一个control在parameter上,用于用户输入。Dataset在一个Athena的view上,view处理了一些数据。





Ref:

[1] https://docs.aws.amazon.com/quicksight/latest/user/parameters-in-a-url.html

[2] https://aws.amazon.com/blogs/big-data/using-quicksight-parameters-and-controls-to-drive-interactivity-in-your-dashboards/

Thursday, October 22, 2020

Java分析内存泄漏问题

 VisualVM - 分析机器上app,CPU,memory运行情况

Apache JMeter - load test 工具,用于人工生成traffic,重现问题

Youkit/Eclipse Profiler - 分析内存泄漏memory leak


本问题是一个网站有memory leak的问题,导致heap memory usage在deployment后都一直上升

步骤

1. 用JMeter产生traffic,且用VisualVM观察问题是否重现且确认收集够数据,就停止收集

2. copy heap dump到安装了Youkit的机器

3. 用Youkit分析memory。发现有大量duplicate objects(Youkit定义是equal field by field或者数组元素一样)。打开QueryLogReporter可以发现这些重复对象都是来源于某一个class。

分析代码后发现,我们用了HTTP intercepter来拦截所有request然后将这些metrics放入一个MetricsManager的对象中,而这些对象并没有有效被删除,导致在ThreadLocal上累积。

找到根本原因后,我们在代码中在每次收集HTTP request后调用这个manager的一个delete函数。

AWS RDS怎么用workbench连上

 创建AWS账号时会自带一个default VPC。


1. 创建RDS时,用上这个VPC

2. 一开始一直Workbench连不上,后来发觉缺少几个设置。设点击主DB instance (非cluster)为publicly accessible。这个设置至关重要,因为根据描述,DB在VPC中,外部设备如workbench和其他VPC都不能访问。否则就要通过[1]的方法,通过SSH到同一VPC下EC2来进行访问。设置了public并不代表任何人都可以访问,因为VPC会有访问限制,详看下一步。

    














3. DB对应的security group(防火墙)inbound规则允许MySQL和3306端口并将我的机器IP (My IP选项或者custom选项用https://checkip.amazonaws.com/ 来查询)加入到白名单中。outbound不用修改。














4. 设置workbench

Hostname: 用主instance (writer)的hostname, **-us-west-2.rds.amazonaws.com

port: 3306

username: admin

pw: 创建实例时候记下的


Ref:

[1] https://www.inoneo.com/en/blog/15/amazon-aws/connect-to-an-aws-rds-instance-inside-a-vpc-using-mysql-workbench


Sunday, October 18, 2020

Use Eclipse to develop AWS lambda

 

1. Setup AWS Toolkit in Eclipse [1]

2. Setup AWS credentials [2]

    The instructions are not quite clear. A few steps required here:

     (1) Create an IAM user without any permissions boundaries

     (2) Add permissions for Lambda, S3, CloudFormation and iam (Inline policy). For iam, the iam:CreateRole is required [3]. But I added full access.


         Note: if there is any error in deploying the lambda, check the missing permssions in CloudFormation events or the AWS console in Eclipse.

3. Create a AWS serverless Java project with hello-world blueprint [4]

4. Deploy the project 

     













5. Test lambda. In lambda service in AWS console (Be sure in the right region), add test event 

"TestInput"

The run the lambda. Check the logs in CloudWatch logs.

 

Ref:

[1] https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/setup-install.html

[2] https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/setup-credentials.html

[3] https://medium.com/@jun711.g/authorizing-aws-cloudformation-role-to-perform-iam-createrole-on-resources-2928e5ca5be7

[4] https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/serverless-projects.html


Thursday, October 1, 2020

Write through cache vs write back cache

 Write-through(直写模式)在数据更新时,同时写入缓存Cache和后端存储。此模式的优点是操作简单;缺点是因为数据修改需要同时写入存储,数据写入速度较慢。


Write-back(回写模式)在数据更新时只写入缓存Cache。只在数据被替换出缓存时,被修改的缓存数据才会被写到后端存储。此模式的优点是数据写入速度快,因为不需要写存储;缺点是一旦更新后的数据未被写入存储时出现系统掉电的情况,数据将无法找回。


Wednesday, April 15, 2020

Error vs Fault 的区别

Error: An understood failure mode that indicates the request was flawed (duplicate device name)
Fault: a failure mode where the request is valid but application failed anyway

Error对应4xx,表示client或者input有问题
Fault对应5xx,表示service或者output有问题

一般而言,应该分类,alarm只应该对fault,有时候不确定时候就先保守地归类为Fault,后面转为Error。