阿里云CDN服务-SDK手册
- 格式:pdf
- 大小:1.05 MB
- 文档页数:54
DataWorks(数据工场)用户指南用户指南控制台阿里云数加平台管理控制台中,您可通过概览页面找到最近使用的项目,进入工作区或对其进行项目配置,也可以创建项目、一键导入CDN。
以组织管理员(主账号)身份登录DataWorks管理控制台页面。
如下图所示:注意:概览界面是根据您的使用情况和创建时间,仅显示三个项目。
一般显示您最近使用和最近的创建时间项目。
页面说明如下:项目:显示您最近打开的三个项目,您可单击对应项目后的项目配置或进入工作区对项目进行具体操作。
您也可进入项目列表下进行相关操作,详情请参见项目列表。
常用功能:您可在此创建项目。
您也可在此一键导入CDN。
注意:如果子账号登录时,没有创建相应的项目,会提示请联系管理员,开通项目权限。
子账号最多显示两个项目,您可以进入项目列表页面查看全部项目。
如果子账号是部署的权限,则不能进入工作区。
阿里云数加平台管理控制台中,您可通过项目列表页面找到该账号下所有项目,可以对项目进行修改服务、进入工作区、配置项目、删除/激活和重试等操作,也可在此创建项目和刷新列表。
操作步骤以组织管理员(主账号)身份登录 DataWorks(数据工场,原大数据开发套件)产品详情页。
单击管理控制台,进入控制台概览页面。
导航至项目列表页面,该页面将显示此账号下的全部项目。
如下图所示:功能说明项目状态:项目一般分为正常、初始化中、初始化失败、删除中、删除五种状态。
创建项目开始会进入初始化中,后一般会显示两种结果初始化失败或正常。
项目创建成功后,您可以执行禁用和删除操作。
项目禁用后,您也可以激活和删除项目,激活后项目正常。
开通服务:您的鼠标移到服务上,会将您开通的服务全部展现出来,一般正常服务的图标会显示蓝色、欠费服务图标显示为红色并有相应的欠费标志、欠费已删除的服务是显示为灰色,一般服务欠费7天之后会自动删除。
项目配置您可通过配置项目操作,对当前项目一些基本属性和高级属性进行设置,主要对空间、调度等进行管理和配置。
qqq1.2.3.4.5.6.7.8.q使用手册产品限制CDN的使用限制都有哪些帐号需在阿里云官网完成帐号实名认证加速的域名必须在工信部完成备案,推荐接入阿里云备案加速域名的源站内容,可选择保存于ECS或OSS;如源站内容不在阿里云,接入需经过人工审核 所有接入CDN的域名都要经过审核,发现以下任意一种情况,CDN目前不支持接入 加速域名无法正常访问或内容不含有任何实质信息加速域名为游戏私服类加速域名为传奇类游戏、纸牌类游戏加速域名为P2P类网站加速域名为彩票类网站加速域名为违规医院和药品类网站加速域名为涉黄、涉毒、涉赌等自动超时拒绝:您的域名因不符合CDN接入规则而拒绝,请您查看之前的反馈结果,合规后可再行申请提交审核。
对于已接入阿里云CDN的域名,会进行定期复审,如发现以上任何一种违规行为,将立即中止该域名的CDN加速,同时中止该用户下所有域名的CDN服务 加速域名处于"停用"状态(包含"审核未通过"状态)超过30天,系统会自动删除该域名相关记录;如果需要继续对该域名进行CDN加速,请重新添加域名加速域名审核通过后,该域名的加速分发就正式生效了么 不是。
加速分发效果正式生效,需要将您的域名指向CDN生成的CNAME域名,需要在DNS服务商处为您的域名添加CNAME记录,从而达到内容分发加速的效果。
CDN加速域名数量限制每个阿里云账户下,最多支持加速20个域名。
如有大量域名加速需求,请提工单申请特殊支持CDN/使用手册q q 1.2.3.4.5.6.IP源站数量限制当前每个加速域名的IP源站数量限制为10个IP地址。
如有特殊场景需要增加IP源站数量,请提工单申请特殊支持缓存刷新、缓存预热操作数量限制有,缓存刷新类操作(包括缓存刷新、缓存预热)的限制是URL刷新:2000条/日/每账户目录刷新:100个/日/每账户快速开始 AliCloud CDN(内容分发网络),建立并覆盖在承载网之上、由分布在不同区域的边缘节点服务器群组成的分布式网络,替代传统以WEB Server为中心的数据传输模式。
CLI Python VersionUser GuideUser GuideAlibaba Cloud Python SDKsSee the Python SDKs of different Alibaba Cloud products and the commands for installing the SDKs in SDK document Python SDK.Scripts usage samplesUse Shell scriptAlibaba Cloud CLI is a tool for the unified management and configuration of Alibaba Cloud resources. After you install and configure Alibaba Cloud CLI, you can use it to manage multiple Alibaba Cloud products and services simultaneously.To facilitate your use of Alibaba Cloud CLI, we have compiled a script integrating common operations. This document shows how to run the sample Shell script in the Linux operating system.Install and configure Alibaba Cloud CLI.For more information about the installation and configuration procedures, see AlibabaCloud CLI installation guide (Linux/UNIX/Mac OS) and Configuration of Alibaba Cloud CLI.Click here to download the script.Run the following command to extract the downloaded script package.tar zxvf ecs.tar.gzsh ecs.shSelect the operation that you want to perform:The following figure shows the operations that you can select in the first directory:The following figure shows the operations that you can select in the seconddirectory:Query information of the subscribed image market imagesYou can run the following script in Alibaba Cloud CLI to query information (image IDs and names) of all subscribed image market images. You can download or edit the script.Click to download the script: querySubscribedImageId.zipThe script is as follows:`#!/bin/bashtcount=`aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --output json --filter TotalCount`pageNum=1cat /dev/null >/tmp/imageids.txtwhile ((tcount>0))doaliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --filter Images.Image[*].ImageId --PageSize 100 --PageNumber $pageNum --output json --filter Images.Image[*].ImageId | sed '1d' | sed '$d' | sed 's/,//g' | sed's/"//g'| sed 's/ //g'>>/tmp/imageids.txtlet pageNum++let tcount-=100donecat /tmp/imageids.txt | while read linedoisSubscribed=`aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --ImageId $line --filterImageIds.Image[*] --filter Images.Image[*].IsSubscribed --output json | sed '1d' | sed '$d' | sed 's/ //g'`if [[ $isSubscribed = "true" ]];thenecho $line `aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --ImageId $line --filter ImageIds.Image[*] --filter Images.Image[*].ImageName --output json | sed '1d' | sed '$d' | sed 's/ //g'` >>imagesInfo.txtfidonenative2ascii -encoding UTF-8 -reverse imagesInfo.txt imagesInfoCN.txtrm -rf imagesInfo.txtcat imagesInfoCN.txt`After editing or downloading the script and granting the permission (by running the chmod + x command), you can run the script in the following format to generate an imagesInfoCN.txt file containing information of subscribed image market images in the directory storing the script.Example:./querySubscribedImageId.shSample output:# ./querySubscribedImageId.shm-23917oqoi "ASP/.NET runtime environment (Windows 2008 64-bit|IIS7.0) V1.0"m-23n2589vc "Java runtime environment (Centos 64-bit|OpenJDK1.7) V1.0"m-23u9mjjtk "PW website construction system (Centos 64-bit) V1.0"Query all instance IDs in a specified region and export them to a fileYou can run the script below in Alibaba Cloud CLI to query all instance IDs in a specified region, and export them to a file. You can choose to download or edit the script.Click to download the script: getVmList.zipThe script is as follows.#!/bin/bashtcount=`aliyuncli ecs DescribeInstances --RegionId $1 --output json --filter TotalCount`pageNum=1cat /dev/null >vmList.txtwhile ((tcount>0))doaliyuncli ecs DescribeInstances --RegionId $1 --PageSize 100 --PageNumber $pageNum --output json --filter Instances.Instance[*].InstanceId | sed '1d' | sed '$d' | sed 's/,//g' | sed 's/"//g'| sed 's/ //g'>>vmList.txtlet pageNum++let tcount-=100donecat vmList.txtAfter you edit or download the script and grant the permission (by running the chmod + x command), you can run the script in the following format to generate a vmList.txt file containing required instance IDs in the directory storing the script.Format:./getVmList.sh <Region ID>Note: You can obtain the Region ID through the DescribeRegions interface.Example:./getVmList.sh cn-hangzhouSample output:#./getVmList.sh cn-hangzhoucn-hangzhou sg-227f611sscn-hangzhou sg-22esa2s7sQuery the VPC instance ID list with no VSwitch created in all regionsYou can run the following script in Alibaba Cloud CLI to query the VPC instance ID list with no VSwitch created in all regions. You can download or edit the script.Click to download the script: getNoVSWitchVpcIds.zip.The script is as follows:#!/bin/bashfor RegionId in `aliyuncli ecs DescribeRegions --filter Regions.Region[*].RegionId --output json | sed '1d' | sed '$d' | sed 's/,//g' | sed 's/"//g'| sed 's/ //g'`docat /dev/null >/tmp/vpcIDs.txtpageNum=1tcount=`aliyuncli ecs DescribeVpcs --RegionId $RegionId --output json --filter TotalCount`while ((tcount>0))doaliyuncli ecs DescribeVpcs --RegionId $RegionId --filter Vpcs.Vpc[*].VpcId --PageSize 50 --PageNumber $pageNum --output json | sed '1d' | sed '$d' | sed 's/,//g' | sed 's/"//g'| sed 's/ //g'>>/tmp/vpcIDs.txtlet pageNum++let tcount-=50donecat /tmp/vpcIDs.txt | while read linedovSwitchCount=`aliyuncli ecs DescribeVSwitches --VpcId $line --output json --filter TotalCount`if [[ $vSwitchCount -eq 0 ]];thenecho $RegionId $linefidonedoneAfter editing or downloading the script and granting the permission (by running the chmod + x command), you can run the script in the following format to export the VPC instance IDs (in pairs) with no VSwitch created in all regions in the Region ID VpcId format by region.Format:./getNoVSWitchVpcIds.shSample output:[root@AliyunTest]# ./getNoVSWitchVpcIds.shcn-hangzhou vpc-23vyarrssQuery IDs of security groups not associated with any instances in all regionsYou can run the following script in Alibaba Cloud CLI to query security groups not associated withany instances in all regions and perform operations (such as DELETE) on the security groups. You can download or edit the script.Click to download the script: getUnUsedSecurityGroupId.zip.The script is as follows:#!/bin/bashfor RegionId in `aliyuncli ecs DescribeRegions --filter Regions.Region[*].RegionId --output json | sed '1d' | sed '$d' | sed 's/,//g' | sed 's/"//g'| sed 's/ //g'`docat /dev/null >/tmp/UnUsedSecurityGroupIds.txtpageNum=1tcount=`aliyuncli ecs DescribeSecurityGroups --RegionId $RegionId --output json --filter TotalCount`while ((tcount>0))doaliyuncli ecs DescribeSecurityGroups --RegionId $RegionId --filter SecurityGroups.SecurityGroup[*].SecurityGroupId --PageSize 100 --PageNumber $pageNum --output json | sed '1d' | sed '$d' | sed 's/,//g' | sed 's/"//g'| sed 's///g'>>/tmp/UnUsedSecurityGroupIds.txtlet pageNum++let tcount-=100donecat /tmp/UnUsedSecurityGroupIds.txt | while read linedousedVMCount=`aliyuncli ecs DescribeInstances --RegionId $RegionId --SecurityGroupId $line --output json --filter TotalCount`if [[ $usedVMCount -eq 0 ]];thenecho $RegionId " " $linefidonedoneAfter editing or downloading the script and granting the permission (by running the chmod + x command), you can run the script in the following format to export IDs of security groups (in pairs) not associated with any instances in all regions by region and security group.Format:./getUnUsedSGInfo.shSample output:[root@AliyunTest]# ./getUnUsedSGInfo.shcn-qingdao sg-227f61ltscn-shenzhen sg-22esa0f7sStructure and parameters of the command lineOnline help commandFor ease of use, Alibaba Cloud CLI provides online help commands. You can use the help commands to query valid operations supported by Alibaba Cloud products.For instance, if you want to query all the operations supported by ECS, run aliyuncli ecs help command and the query result is shown as follows.If you want to query the parameters of an ECS operation, run aliyuncli ecs <operation name> help. Taking the DescribeRegions operation as an example, the query result is shown as follows.Alibaba Cloud CLI command structureThe Alibaba Cloud CLI command structure is as follows.aliyuncli <command> <subcommand> [options and parameters]aliyuncli: Alibaba Coud CLI, the tool name of Alibaba Cloud.command: a top-layer command which represents an Alibaba Cloud basic service supported by Alibaba Cloud CLI (such as ECS/RDS/SLB/OSS), or a command of Alibaba Cloud CLI (such as “help” and “configure”).subcommand: a subcommand that specifies an operation to be executed, that is, a specificoperation.options and parameters: the parameter list corresponding to the operation specified insubcommand. The ordering of the parameters has no impact on the use of commands.Various types of input values can be used, such as numbers, strings, lists, mappings, andJSON structures.Examples:aliyuncli rds DescribeDBInstances --PageSize 50aliyuncli ecs DescribeRegionsaliyuncli rds DescribeDBInstanceAttribute --DBInstanceId xxxxxxParameter value input requirementsWhen you are calling Alibaba Cloud CLI, you must input the required values according to the following instructions to avoid errors.In most cases, you are required to input a string or numeric value to Alibaba Cloud CLI.Example:$ aliyuncli ecs DescribeInstanceAttribute --InstanceId myInstanceIdIf your inputs contain spaces, use single quotation mark (‘) to include the value. This manner is applicable to Windows PowerShell, Mac OS, and Linux.Example:$ aliyuncli ecs DescribeInstanceAttribute --InstanceId 'my instance id'For Windows Command Processer, use double quotation marks (“) to include the value.Example:> aliyuncli ecs DescribeInstanceAttribute --InstanceId "my instance id"Use JSON format to input parameters. JSON format is allowed in Alibaba Cloud CLI. Especially, when you query information of multiple instances or multiple disks, you can input multiple ID values in JsonArray format. It requires that you strictly edit data in JSON format and perform special processing on double quotation marks (“) in JSON format.To query information of multiple instances, you can input values with double quotation marks (“), like [“my-intances-id1”, “my-instances-id2”]. However, in Python, the double quotation marks (“) are filtered out by default, so special processing is required.On Linux and Mac OS systems, use single quotation mark (‘) to include the entireJSON value.Example:$ aliyuncli ecs DescribeInstances --InstanceIds '["my-intances-id1", "my-instances-id2"]'In Windows Command Processer, use a backslash ( \ ) to represent the doublequotation mark (“), and use double quotation marks (“) to include the entireJSON value.Example:> aliyuncli ecs DescribeInstances --InstanceIds "[\"my-intances-id1\", \"my-instances-id2\"]"In Windows PowerShell, use a backslash ( \ ) to represent the double quotationmark (“), and then use single quotation mark (‘) to include the entire JSON value.Example:> aliyuncli ecs DescribeInstances --InstanceIds '[\"my-intances-id1\", \"my-instances-id2\"]' Command output formatOutput formatTo meet different output format requirements of different users, Alibaba Cloud CLI supports three output formats.JSON (json)JSON format is the default output format of Alibaba Cloud CLI. Most languages have theinternal function or open JSON parser library to parse JSON strings easily. JSON format ismainly used with other scripts or any programming language to facilitate developers’parsing and use. An example is shown as follows.Text separated by Tab (text)In text format, outputs of Alibaba Cloud CLI are arranged into lines separated by Tab. This format is appropriate for traditional UNIX text tools (such as sed, grep, and awk) and Windows PowerShell. The text output format complies with the basic structure shown in the following example. The columns are sorted alphabetically by key names of bottom-layerJSON objects.In table format, data is arranged in an easy-to-read manner. An example is shown as follows.Set the output formatThe output format can be specified in two ways.Method 1: Modify the config file.Use the output option in the config file. The following example shows how to set the output formatto text.Method 2: Use command line.Use the output option in Alibaba Cloud CLI. The following example shows how to set the output format to table.Global parameter descriptionWhen you are using Alibaba Cloud CLI, you can set temporary settings for global parameters. You canadjust the parameters as needed. Currently, the supported global parameters are as follows:AccessKeyId: Specifies the AccessKeyId in the API request for executing the currentcommand. If no value is specified or the value is null, the default global AccessKeyId is[default] output=text $ aliyuncli ecs DescribeInstanceAttribute --InstanceId i-23rjh06vf --output tableapplied.AccessKeySecret: Specifies the AccessKeySecret in the API request for executing the current command. If no value is specified or the value is null, the default global AccessKeySecret isapplied.RegionId: Specifies the region corresponding to the API request for executing the currentcommand. If no value is specified, the global RegionId is applied.output: Specifies the display format for executing the current command.profile: Specifies the account used for executing the current command. If the specifiedaccount does not exist, the default account is used. In addition, if profile appears togetherwith other global parameters, its priority is lower. For example, if profile appears togetherwith AccessKeyId, AccessKeyId is selected as the AccessKey preferentially.version: Specifies the open API version used for executing the current command. If no value is specified, the latest version installed in the system is used.Note: If the parameter directly follows Alibaba Cloud CLI, the current version of AlibabaCloud CLI is displayed.Multi-account useMulti-account useNotices: This feature is useful for users who need to manage many accoutns and many devices. If you only need to manage an accout, ignore this feature.Alibaba Cloud CLI supports multi-account systems. You can configure multiple access keys and secret values, region and output as needed, to meet your different requirements more flexibly. For the information about how to configure accouts in Alibaba Cloud CLI, refer to Configuration of Alibaba Cloud CLI (for Alibaba Cloud users).Basic command structureThe basic command structure of multi-accout management is shown as follows:aliyuncli configure [set/get/list] --profile profilename --key value --key1 value1configure: Manage configurations.set: Set a configuration value. Optional.get: Display a configuration value. Optional.list: List all values of a profile. Optional.profile: Profile used in the current operation, which is a global parameter. For details, refer to the description of profile in Global parameter description. If this option is not included, adefault account is used.key: Specific key for configuring a profile.Value: Value being configured, which is behind key.Accout typeThere are two kinds of accounts in the config file: [default] account and [profile profilename] account. In Alibaba Cloud CLI, if the option profile is not included, the [default] account is used; if the option profile profilename is included, [profile profilename] is used.The following shows the examples of profile:aliyuncli configure ←Configure [default] account quicklyaliyuncli configure --profile test ←Configure [profile test] account quicklyThe following shows the examples of set:aliyuncli configure set --output table --region cn-qingdao ←Set [default] account, output=table, region=cn-qingdaoaliyuncli configure set --output json --region cn-hangzhou --profile test1 ←Set [profile test1] account, output = json, region = cn-hangzhouThe following shows the examples of get:Output: region = cn-hangzhouOutput:output = jsonregion = cn-hangzhouThe following shows the examples of list:The output is as follows:Advanced filter functionNote : This feature is used for users who have many instances. If you have only one instance, ignorethis feature.Data returned upon Alibaba Cloud API calls can be presented in different formats, but it is alsocomplex. Alibaba Cloud CLI further provides the data filter function, allowing you to filter data usingfilters. The filter function can help you obtain the expected value from the result, and can be used tohandle results easily and quickly in use or secondary development.Data returned upon API calls is in JSON format by default. Therefore, when using Alibaba Cloud CLI,aliyuncli configure get region ←Get the region of [default] accountaliyuncli configure get output region ←Get the output and region values of [default] accountaliyuncli configure get region --profile profile1 ←Get the region under [profile profile1] accountaliyuncli configure list ←List information under [default] accountaliyuncli configure list --profile profile1 ←List information under [profile profile1] accountyou can use the filter function according to JSON characteristics to obtain your expected results.Taking ECS DecribeRegions for example, run the following command, and the original JSON format output is shown as follows.aliyuncli ecs DescribeRegions --output jsonFilter 1You can enter a key value for filtering. Run the following command, and the filter output is shown as follows.aliyuncli ecs DescribeRegions –output json –filter RegionsFilter 2If the JSON value is an array, the array subscript format is supported. Run the following command,and the filter output is shown as follows.Especially, Alibaba Cloud CLI also supports ‘*’, representing the set of all results. Multiple filterresults are returned as an array. Run the following command, and the filter output is shown as follows.Filter 3 Filter one value from the returned data. Run the following command, and the filter output is shown asaliyuncli ecs DescribeRegions –output json –filter Regions.Region[0]aliyuncli ecs DescribeRegions –output json –filter Regions.Region[*].RegionIdfollows.aliyuncli ecs DescribeRegions –output json –filter Regions.Region[3].RegionId。
cdn的设计原理- - 峰云就她了introduce 什么是 CDN, 内容分发⽹络为什么要用cdn ?cdn的关键组件cdn 内部实现原理, 架构拓扑及优化⽅法源站层面的cdn架构及优化⽹页层面的cdn架构及优化dns cdnserverHTMLbrower涉及的内容cdn基本原理内容缓存到不同地区的缓存服务器实现就近访问原则通过dns view 和 load status调度到不同的边缘节点cdn target 构建边缘节点, 解决最后”⼀公里”智能调度 (负载均衡, 故障屏蔽 , 就近访问)智能路由 (寻找最优访问链路)安全防护 (强⼤带宽, 边缘计算能⼒)source - BJ1.1.1.1client - QDcdn - QD2.2.2.250 ms10 mshtml view/a.jpg/b.jpg/c.jpg/a.jpgDNSstatic A 2.2.2.2* A 1.1.1.1* A 2.2.2.2why use cdn ?90%流量 : static zone30 mshandler request costdns scheduler Edge Cache SH Edge Cache BJEdge Cache GZsource LBLdnsx NS.com/.xxxroot“ Http Headers , Abort cache http protocol”Expires vs Cache-Control max-age200 from cache vs 304when F5 vs ctrl + F5 , add args in request headerF5 —> Cache-Control: max-age=0 ; If-Modified-Since。
Ctrl F5 —> Cache-Control: no-cache Pragma: no-cacheLast-Modified + If-Modified-Since vs Etag + If-None-Matchno-cache vs no-storein reuqest headerno-cache , not get cache data (CTRL + F5)no-store , Nonein response headerno-cache , Allow cache actionchrome : reqeust again , Check 304 every time.ie9/FF : request again , Not cache datano-store , Prohibit cache action ,get file from source, All node not cache .http headerX-Cache : HIT from X-Forwarded-For : client_ip proxy1_ip proxy2_ipVia : cache42.l2nu16-1[0,200-0,H], cache6.l2nu16-1[8,0]Age : cache ageRange : bytes=500-999“ schduler zone contains view dns and eachcache load ”smart dnsviewip dbednsrule prioritycollect可用性探测Host存活Service存活性能探测流量cpu / memdisk iops服务注册dns cluster NS2cc dnsRTT 指标root dns NS1LVSanycast dns cluster 青岛1.1.1.1上海1.1.1.1北京 1.1.1.1利用一个/多个 bgp as 号码在不同的地区广播相同的一个ip段 anycast就是不同的服务器用了相同的ip地址对坑攻击, 区域隔离 !“ cache server optimize”simple cdn diff平台存储性能共享存储功能squid disk/mem 2.7单核 > 3.x多核多级存储acl, icp, rate等等varnish mem极⾼只能内存基本的acl,purgenginx mem/disk⾼多级存储功能多, 可module扩展ats mem/disk很⾼裸盘多级存储功能强⼤, icpproxy network io| | | | || | | | |epollbuffersourcemem returnreturnlvs dr 提⾼流量nginx/haproxy 引流⼀致性hash 提⾼hit 探测⾼可用移除lb 镜像站cache server 上报状态Cache Load Balance 选型vrrpLB(Nginx/Haproxy)LVSLB(Nginx/Haproxy)AtsAtsAtsAtsLVS⼆级cache and icpL2L1sourceL1 L2 percent ?icpcdn secure + securewafddos流量清洗cclimit rate or drop验证码页面js insert cookie token , cdn diff tokenddos & ccmpls引流正常状态清洗回注SYN反查路由success connproxy透传ACKsyn cookieESlimit connactive counter 伪造源IP⼤字节SYN混乱型ACKConnection Floodip rate limitjs input tokencookie js 302pull vs push pullops submit urls ,then cdn requests the urls.pushcdn push files to cdn storequickly push cache files with p2puse icp protocol in the same zone多级cachemem ssd diskhotcold 推荐百分比 mem: ssd: sata = 1: 10: 100顶层hash map判断该⽂件的level位置每个level cache都有数据位置表及Lru表lru = double linked list + hash maphash map存放linked nodeLru 长度是由level 字节动态控制| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 顶层hash定位level————————————————| | | | |Hash ( List’ s node )Lru deque调整时需先copy后del置换空间 15 %预留空间 5 %| | | | | | | | | | |————————————————————————————————satassdmemory多级cache 起初mem —> ssd —> disk使用Lru淘汰冷⽂件, 超过阈值后主动淘汰, 定时调节各level cache不使用raid, 如磁盘不可读, 摘掉cache server内置disk的调度⼀致性hash⼤⽂件直接到diskcoss 小⽂件, aufs ⼤⽂件. 可同时使用裸盘的急速体验扩展purge盗链 (refer, token)限速for source serverfor client⽂件合并及压缩cdn 优化选择性的ignore (reload \ no-cache)304不⾛磁盘使用libaio (内核AIO)视频分片cdn server ——> web server , spdy + tfo万兆⽹卡是标配https装载卸载, ssl 加速卡 ?使用trie树快速匹配, (purge, ⿊名单, ip View)“ soruce server frame optimize ”simple bgp describelualu通告 203.118.14.10/30un125.201.14.13/30ct203.118.14.9/30* 小白 *通过 125.201.14.14/30bgp ip rangegateway解决单ip多线路 !!!AS 9504AS 1111AS 2222source zoneLBwebfuser/apifile serverfastdfsgfscephglusterospflvs/mm.jpg“ html code optimize ”动静分离after end template + fore-end mvc优点并⾏开发调试服务化后端模板渲染及传输成本缺点seo, seo, seoESI Include vs 静态化切割域名提⾼brower并发提⾼可用性, 页面的静态⽂件不会全部都挂监听服务端的缓存热点压⼒brower限制同⼀域名下并发数引用外联地址的作用及⽅法domain hashcookie freenews<esi:include src=“top_news.php” max-age="45"/>csiiframe, ajax …ssiinclude fileonly source serveresipageage in edge cache <esi:include src=“comment.php” max-age="45"/>ESI vs SSI vs CSI“ debug cache server ”dns调度测试[ruifengyun@devops ~ ]$ dig @180.153.225.136 ...;; ANSWER SECTION:. 385 IN CNAME . . 30 IN A 122.228.74.183 [ruifengyun@devops ~ ]$ dig @114.114.114.114 ;; ANSWER SECTION:. 180 IN CNAME . . 180 IN A 119.167.151.224 [ruifengyun@devops ~ ]$ dig @8.8.8.8 ;; ANSWER SECTION:. 599 IN CNAME . . 179 IN A 222.161.210.45[ruifengyun@devops ~ ]$ curl -I /china/ HTTP/1.1 200 OKServer: nginxDate: Tue, 21 Jun 2016 05:31:19 GMTContent-Type: text/htmlLast-Modified: Tue, 21 Jun 2016 04:34:29 GMTVary: Accept-EncodingExpires: Tue, 21 Jun 2016 05:32:19 GMTCache-Control: max-age=60X-Powered-By: schi_v1.02X-Cache: HIT from ETag: "57451990-481"[ruifengyun@devops ~ ]$ curl -I /china/…X-Powered-By: schi_v1.02[ruifengyun@devops ~ ]$ curl -I /china/ HTTP/1.1 200 OKServer: nginxDate: Tue, 21 Jun 2016 05:31:19 GMTContent-Type: text/htmlLast-Modified: Tue, 21 Jun 2016 04:34:29 GMTVary: Accept-EncodingExpires: Tue, 21 Jun 2016 05:32:19 GMTCache-Control: max-age=60X-Powered-By: schi_v1.02X-Cache: HIT from ETag: "57451990-481"[ruifengyun@devops ~ ]$ curl -I /china/…X-Powered-By: schi_v1.02[ruifengyun@devops ~ ]$ curl -I HTTP/1.1 200 OKServer: T engineContent-Type: text/html; charset=UTF-8Content-Length: 105749Connection: keep-aliveVary: Accept-EncodingDate: Tue, 21 Jun 2016 05:26:40 GMTX-Powered-By: PHP/5.3.3Cache-Control: max-age=3, must-revalidateWP-Super-Cache: Served supercache file from PHPVia: cache24.l2nu16-1[0,200-0,H], cache20.l2nu16-1[1,0], 239[0,200-0,H], 239[0,0]Age: 2504X-Cache: HIT TCP_MEM_HIT dirn:9:536240464常见问题切细static资源域名ttl Ldns强制延长, A记录主机宕机了, how ?httpdns新增的节点, 需跑热被劫持到isp cache, how ?链路劫持, httpsmore…“Q & A”– 。
cdn用法一、CDN基本用法1. CDN就像一个超级快递员,把你网站的内容快速送到用户那里。
你只要把你的静态资源,像图片、脚本和样式表等,放到CDN上。
哇塞,就好像给它们装上了火箭助推器,速度超快的!比如说,我的小网站以前加载图片要等老半天,那感觉就像蜗牛在爬。
自从用了CDN,嘿,图片“嗖”的一下就出来了,就像闪电一样快。
2. 要使用CDN呢,你得先选择一个靠谱的CDN服务提供商。
这就跟你找个好帮手似的。
你看,有的CDN提供商全球都有节点,就像在世界各地都有小仓库。
我有个朋友,他的网站面向全球用户。
没使用CDN之前,国外用户访问他的网站那叫一个慢,都快把他急哭了。
后来用了CDN,全球用户访问速度都大大提升了,他高兴得像中了彩票一样。
3. 把你的资源链接指向CDN的地址,这一步很关键哦。
就好比你告诉快递员包裹要送到哪里。
如果搞砸了,那可就麻烦了,就像你把地址写错了,包裹就送不到正确的地方。
我曾经就犯过这个错,结果网站上有些图片显示不出来,我当时那个懊恼啊,就像丢了心爱的玩具。
4. CDN还能缓存内容呢。
这就像在每个小仓库里都存了一份你的货物,下次有人要的时候,直接从最近的仓库拿就行了。
我的网站有一些经常被访问的脚本文件,没CDN缓存的时候,每次都要重新从服务器获取,慢得要死。
有了CDN缓存,那速度,啧啧,就像开了挂一样。
5. 对于网站优化来说,CDN可是个神器。
它能减轻源服务器的压力。
你想啊,要是所有的请求都涌向源服务器,那服务器得多累啊,就像一个人扛着好多好多东西,都快被压垮了。
使用CDN之后,就像多了一群小伙伴来帮忙分担,源服务器轻松多了。
二、CDN固定搭配(以常见的和HTML、网站性能优化相关为例)1. CDN与HTML中的脚本标签搭配使用。
你可以在HTML文件里,把脚本文件的源地址换成CDN提供的地址。
比如说,如果你用的是JQuery 库,你可以从JQuery的官方CDN获取它。
这就好比你做蛋糕,不从自己家找材料,而是直接从专业的烘焙店拿现成的优质材料,又方便又好。
快速上⼿阿⾥云ossSDK使⽤阿⾥云oss SDK依赖安装:pip install oss2pip install aliyun-python-sdk-sts版本最好是 2.7.5 或以上如果要开启 crc64 循环冗余校验,需要先将 crcmod 安装好。
安装 python-devel 执⾏ yum install python-devel。
需要循环冗余校验,安装 crcmod 执⾏ pip install crcmod。
获取AccessKeyId和AccessKeySecret:1. 登录阿⾥云控制台。
2. 将⿏标放在右上⽅的⽤户名区域,在弹出的快捷菜单中选择accesskeys。
3. 系统弹出安全提⽰对话框,单击继续使⽤AccessKey。
页⾯显⽰AccessKeyId和AccessKeySecret。
快速创建⼦账号AccessKey:1. 使⽤主账号登录阿⾥云控制台。
2. 将⿏标置于页⾯右上⽅的账号图标,然后单击accesskeys。
3. 在安全提⽰框中,单击开始使⽤⼦⽤户AccessKey。
4. 填写RAM⽤户名,然后单击下⼀步。
5. 给RAM⽤户授予相关权限,例如AliyunOSSFullAccess将给RAM⽤户授予OSS的管理权限。
单击开始创建。
6. 完成⼿机验证后,单击确定。
7. 查看AccessKeyId和AccessKeySecret。
然后单击下载AccessKey,下载AccessKey信息。
整体使⽤⽅法:# -*- coding: utf-8 -*-import oss2endpoint = '' # Suppose that your bucket is in the Hangzhou region.auth = oss2.Auth('<Your AccessKeyID>', '<Your AccessKeySecret>')bucket = oss2.Bucket(auth, endpoint, '<your bucket name>')# The object key in the bucket is story.txtkey = 'story.txt'# Uploadbucket.put_object(key, 'Ali Baba is a happy youth.')# Downloadbucket.get_object(key).read()# Deletebucket.delete_object(key)# Traverse all objects in the bucketfor object_info in oss2.ObjectIterator(bucket):print(object_info.key)创建存储空间:# -*- coding: utf-8 -*-import oss2# 阿⾥云主账号AccessKey拥有所有API的访问权限,风险很⾼。
阿⾥云SDK⼿册之javaSDK进⾏阿⾥云sdk开发的前提是已经购买阿⾥云的相关服务才能调⽤阿⾥的相关接⼝进⾏开发。
最近公司在做云管控的项⽬,于是进⾏下摘录总结。
⼀. 环境准备阿⾥云针对不同的开发语⾔提供不同的sdk,由于项⽬⽤的是java语⾔进⾏开发,所以下载的是java sdk,介绍的也是java sdk的开发⽅式。
1.⾸先下载服务的SDK,阿⾥云Java SDK⽀持J2SE Development Kit (JDK) 1.5或以上版本。
2.安装步骤1. 在解压的⽂件中可以找到 aliyun-sdk-java-online_standard-20141010.jar 这个包;2. 以Eclipse为例导⼊jar包的过程如下:在Eclipse上右键点击⼯程 -> Properties -> Java Build Path -> Libraries -> Add ExternalJARs(netbeans和intellij等其他idea⽤户请⾃⾏按照相应导⼊jar包得⽅法导⼊这个包);3. 选择以上jar包,点击“OK”按钮,经过以上步骤,你就可以在⼯程中使⽤阿⾥云Java SDK了。
⼆.快速⼊门1.初始化⼀个AliyunClient1. 与阿⾥云SDK相关的类都在包com.aliyun.api.AliyunClient下;2. AliyunClient是与API交互的接⼝,SDK的操作都是通过AliyunClient完成的;3. AliyunClient可以复⽤,建议设置成应⽤程序全局唯⼀的;4. ⽤户可以调⽤带有connectTimeout和readTimeout的构造⽅法来设置SDK调⽤接⼝的连接超时时间和读取超时时间,SDK默认的连接超时时间是3秒,读取超时时间是80秒。
⽰例代码如下:import com.aliyun.api.AliyunClient;import com.aliyun.api.DefaultAliyunClient;public class CreateAliyunClientDemo {private static AliyunClient client;static {String serverUrl = "<serverUrl>"; //例如: /String accessKeyId = "<accessKeyId>";String accessKeySecret = "<accessKeySecret>";// 初始化⼀个AliyunClientclient = new DefaultAliyunClient(serverUrl, accessKeyId, accessKeySecret);}public static void main(String[] args) {}}2.SDK调⽤⽰例调⽤步骤:1. 实例化⼀个请求类,根据调⽤API的不同版本实例化不同Java包下的请求类;2. 给请求实例赋值;3. 调⽤接⼝返回调⽤结果。
--App SDK 手册Android SDK手册使用前必读:移动推送名词解释&约束1. 创建应用到阿里云移动推送控制台创建应用,应用创建完成以后,进入移动推送相关模块进行设置,具体操作请参见 创建APP 。
在应用中完成应用配置,请注意PackageName务必和App的包名一致,否则推送将无法正确初始化。
【注意】使用Gradle构建App时,PackageName的查看:查看AndroidManifest.xml中根元素package属性;查看工程build.gradle中applicationId设置,默认AndroidManifest.xml中的package属性保持一致,如果不一致,以applicationId为准。
2. SDK下载和集成2.1 SDK下载2.2 SDK目录结构OneSDK|-- AndroidManifest.xml|-- build.gradle|-- libs--2.3 SDK集成:请在工程中添加android-support-v4.jar支持包(v2.3.0以上),关于v4支持包的说明请参考:https:///topic/libraries/support-library/features.html#v4;手动拷贝下载SDK中的libs目录,手动拷贝后需要在APP工程的build.gradle中配置jniLibs的目录:3. 配置AndroidManifest.xml3.1 appkey和appsecret配置com.alibaba.app.appkey和com.alibaba.app.appsecret为您App的对应信息,在推送控制台APP列表页的应用证书中获取。
| |-- armeabi| | |-- libcocklogic.so -网络连接库及幽灵进程的辅助lib| | |-- libtnet.so| |-- armeabi-v7a| | |-- libcocklogic.so| | |-- libtnet.so| |-- arm64-v8a| | |-- libcocklogic.so| | |-- libtnet.so| |-- x86| | |-- libcocklogic.so| | |-- libtnet.so| |-- arm64| | |-- libcocklogic.so| | |-- libtnet.so| |-- alicloud-android-push-sdk.jar -移动推送主功能包| |-- alisdk-ut.jar -UT基础包| |-- utdid4all.jar -设备Id生成包|-- project.properties|-- srcandroid {...sourceSets {main {jniLibs.srcDirs = ['libs']}}}<meta-data android:name="com.alibaba.app.appkey" android:value="*****"/> <!-- 请填写你自己的- appKey --><meta-data android:name="com.alibaba.app.appsecret" android:value="****"/> <!-- 请填写你自己的appSecret -->--3.2 Permission 的配置将以下uses-permission片段拷贝进你manifest中的Permission申明区域中:3.3 Service 的配置将以下service片段拷贝进你Manifest中的service申明区域中:<!--阿里移动推送相关权限--><!--Android 6.0版本可去除,用于选举信息(通道复用)的同步--><uses-permission android:name="android.permission.WRITE_SETTINGS" /><!--进行网络访问和网络状态监控相关的权限声明--><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><!--允许对sd卡进行读写操作--><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><!--网络库使用,当网络操作时需要确保事务完成不被杀掉--><uses-permission android:name="android.permission.WAKE_LOCK" /><!--用于读取手机硬件信息等,用于机型过滤--><uses-permission android:name="android.permission.READ_PHONE_STATE" /><!--选举使用,当应用有删除或者更新时需要重新选举,复用推送通道--><uses-permission android:name="android.permission.BROADCAST_PACKAGE_CHANGED" /><uses-permission android:name="android.permission.BROADCAST_PACKAGE_REPLACED" /><uses-permission android:name="android.permission.RESTART_PACKAGES" /><!--补偿通道小米PUSH使用,不用可去除--><uses-permission android:name="android.permission.GET_TASKS" /><!--补偿通道GCM使用,不使用可去除--><uses-permission android:name="android.permission.GET_ACCOUNTS" /><!--允许监听启动完成事件--><uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><!--允许访问震动器--><uses-permission android:name="android.permission.VIBRATE" /><!-- 通道保持服务 --><service android:name="com.alibaba.sdk.android.push.ChannelService"android:exported="true" android:process=":channel"><intent-filter><action android:name="com.taobao.accs.intent.action.SERVICE"/></intent-filter><intent-filter><action android:name="org.agoo.android.intent.action.PING_V4" /><category android:name="taobao" /></intent-filter></service><!-- 消息接收服务 --><service android:name="com.alibaba.sdk.android.push.MsgService"android:exported="false"><intent-filter><action android:name="com.taobao.accs.intent.action.RECEIVE" /></intent-filter>3.4 Receiver 的配置将以下receiver片段拷贝进你manifest中的receiver申明区域中:4. Proguard配置 <intent-filter><action android:name="com.alibaba.sdk.android.push.NOTIFY_ACTION" /></intent-filter></service><!-- 连接心跳保持监听器 --><receiver android:name="anet.channel.heartbeat.HeartbeatManager$Receiver" ><intent-filter><action android:name="MAND" /></intent-filter></receiver><!--消息接收监听器--><receiver android:name="com.alibaba.sdk.android.push.MessageReceiver"><intent-filter><action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED"/></intent-filter><intent-filter><action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED"/></intent-filter><intent-filter><action android:name="MAND" /></intent-filter><intent-filter><action android:name="MAND" /></intent-filter><intent-filter><action android:name="org.agoo.android.intent.action.RECEIVE" /></intent-filter><intent-filter><action android:name=".conn.CONNECTIVITY_CHANGE" /></intent-filter><intent-filter><action android:name="ER_PRESENT" /></intent-filter><intent-filter><action android:name="android.intent.action.BOOT_COMPLETED"/></intent-filter><intent-filter><action android:name="android.intent.action.PACKAGE_REMOVED"/><data android:scheme="package"/></intent-filter></receiver>5. 在应用中注册和启动移动推送首先通过PushServiceFactory获取到CloudPushService,然后调用register()初始化并注册云推送通道,并确保Application上下文中进行初始化工作。