(更新时间)2021年6月2日 商城高并发秒杀系统(.NET Core版) 22-性能优化-SkyWalking的使用
如何使用SkyWalking
条件
1、JDK1.8
2、Elasticsearch 6.6.0
3、SkyWalking
4、SkyAPM-dotnet
5、api网关
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
步骤
1、JDK 1.8操作
1.1 jdk1.8下载
2、Elasticsearch 6.6.0操作
2.1 Elasticsearch 6.6.0下载
下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-6-0
2.2 Elasticsearch 6.6.0配置
解压后,在elasticsearch-6.6.0/config目录下,在elasticsearch.yml内配置
network.host: 0.0.0.0
增加
thread_pool.bulk.queue_size: 1000
- 1
- 2
- 3
2.3 Elasticsearch 6.6.0启动
解压后,在elasticsearch-6.6.0/bin目录下,双击启动
elasticsearch.bat
- 1
2.4 Elasticsearch 6.6.0访问
输入访问地址:http://localhost:9200,显示页面,安装成功
3、 SkyWalking操作
3.1 SkyWalking 下载
下载地址:http://skywalking.apache.org/downloads/
3.2 SkyWalking 配置
解压后,在apache-skywalking-apm-bin/config目录下,在application.yml内配置
elasticsearch:
nameSpace: ${SW_NAMESPACE:""}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"}
trustStorePath: ${SW_SW_STORAGE_ES_SSL_JKS_PATH:"../es_keystore.jks"}
trustStorePass: ${SW_SW_STORAGE_ES_SSL_JKS_PASS:""}
user: ${SW_ES_USER:""}
password: ${SW_ES_PASSWORD:""}
indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2}
indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0}
# Those data TTL settings will override the same settings in core module.
recordDataTTL: ${SW_STORAGE_ES_RECORD_DATA_TTL:7} # Unit is day
otherMetricsDataTTL: ${SW_STORAGE_ES_OTHER_METRIC_DATA_TTL:45} # Unit is day
monthMetricsDataTTL: ${SW_STORAGE_ES_MONTH_METRIC_DATA_TTL:18} # Unit is month
# Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html
bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:1000} # Execute the bulk every 1000 requests
flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests
concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests
resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
注释配置
# h2:
# driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
# url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
# user: ${SW_STORAGE_H2_USER:sa}
# metadataQueryMaxSize: ${SW_STORAGE_H2_QUERY_MAX_SIZE:5000}
- 1
- 2
- 3
- 4
- 5
3.3 SkyWalking-webapp配置
切换到apache-skywalking-apm-bin/webapp目录,在webapp.yml配置
server:
port: 8081
- 1
- 2
3.4 SkyWalking 启动
解压后,在apache-skywalking-apm-bin/bin目录下,双击启动
startup.bat
- 1
3.4 SkyWalking
输入地址进行访问:http://localhost:8081,响应结果,安装成功
4、SkyAPM-dotnet操作
4.1 SkyAPM-dotnet下载
源码地址:https://github.com/SkyAPM/SkyAPM-dotnet#examples
.net core项目配置
项目中,Nuget安装
Nuget SkyAPM.Agent.AspNetCore
- 1
项目中,创建
skyapm.json
- 1
在skyapm.json文件中添加
{
"SkyWalking": {
"ServiceName": "AggregateService",
"Transport": {
"gRPC": {
"Servers": "localhost:11800"
}
}
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
项目launchSettings.json文件中,配置
"environmentVariables": {
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "SkyAPM.Agent.AspNetCore"
}
- 1
- 2
- 3
启动进行访问
输入网关访问地址
http://localhost:5004:/AggregateService/api/teams
- 1
- 2
- 3
打开链路监控中心,可以查看监控信息
文章来源: codeboy.blog.csdn.net,作者:愚公搬代码,版权归原作者所有,如需转载,请联系作者。
原文链接:codeboy.blog.csdn.net/article/details/117478180
- 点赞
- 收藏
- 关注作者
评论(0)