找个前端开始学~ 年纪大了,只能看得懂一些勉强能够看得懂的东西了~
2016-09-01Angular 2 是一个用 HTML 和 JavaScript 或者一个可以编译成 JavaScript 的语言(比如 Dart 或者 TypeScript ),来构建客户端应用的框架。
该框架包括一系列紧密合作的库,有些是核心库,有些是可选库。
我们是这样写 Angular 应用的:用带 Angular 扩展语法的 HTML 写 模板 , 用 组件 类管理这些模板,用 服务 添加应用逻辑, 并在 模块 中打包发布组件与服务。
然后,我们通过 引导 顶级 根模块 来启动该应用。 Angular 在浏览器中接管、展现应用的内容,并根据我们提供的操作指令响应用户的交互。
ionic platform add ios 报错
2016-08-22在安装官方指引创建了一个ionic v2的app之后,执行platform add ios报错:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$ ionic platform add ios Adding ios project... Creating Cordova project for the iOS platform: Path: platforms/ios Package: io.ionic.starter Name: V2 Test iOS project created with cordova-ios@4.2.0 Running command: /Users/nishurong/PhpstormProjects/ionic-workspace/H5APP/hooks/after_prepare/010_add_platform_class.js /Users/nishurong/PhpstormProjects/ionic-workspace/H5APP Error: spawn EACCES |
解决方案是:
1 2 3 |
$ ionic hooks add Adding in default Ionic Cordova hooks Added default Ionic Cordova hooks |
然后继续执行add ios,即可。
注意,先进入platforms目录,如果存在ios目录,先删除掉,否则,执行run ios命令的时候,会出现下面的错误:
1 2 3 4 |
/Users/xueron/PhpstormProjects/ionic-workspace/H5APP/platforms/ios/V2 Test/Classes/MainViewController.h:28:9: fatal error: 'Cordova/CDVViewController.h' file not found #import <Cordova/CDVViewController.h> ^ 1 error generated. |
Phalcon 和 Laravel 的效率还是差很多的。
2016-07-21一直很喜欢Laravel的项目结构设计,很喜欢它和rails的控制台工具。但是项目中一直在用Phalcon,无他,简单、熟悉了。而且,性能上确实非常非常好!
看了很多评测的,今天抽空自己做了一点点测试,看的结果更加直观:
环境:Mac、PHP7.0.8、Phalcon 2.1.0RC、Larave 5.2.40
程序:
Laravel使用默认环境,创建一个Index控制器,一个index方法,显示一行文字。使用optimize优化了。
Phalcon由于没有使用脚手架工具创建项目,自己手工搭建一下,主要就是创建路由、定义视图、挂载模板引擎(volt),将这些注入到di中,同样一个控制器,一个方法,显示同样的模板。
测试:ab -c 10 -n 1000 http://pails.xueron.com/ ,其中c是并发,n是请求总次数。调整两个参数,反复测试。
结果:
基本上laravel的rps(Requests per second)一直在25~40之间。一般为30多点。
而Phalcon的rps基本保持在500+,在500~650之间。
差太多啊~
虚伪的灵魂 做了比较详细的测试:http://xwsoul.com/posts/1071,可以看到,效率主要差在stat/lstat/open/access这些文件的查找与打开上面了。看过Laravel的源码,在依赖注入的设计上面很精巧,但是也带来的问题,就是加载、反射、反复查找~, 效率牺牲的可不是一点半点。
所以打算做个小项目,就是为Phalcon弄一个简单的架子,什么di的服务、配置等等弄弄好,这样用phalcon建项目easy一点……
测试结果:
php-fpm运行larave的情况,可以看到时间耗用和CPU的占用都挺大:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
[www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=195.914 Mem=2048 Cpu=U:40.83%;S:5.10%;T:45.94% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=210.408 Mem=2048 Cpu=U:38.02%;S:4.75%;T:42.77% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=207.224 Mem=2048 Cpu=U:38.61%;S:4.83%;T:43.43% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=197.408 Mem=2048 Cpu=U:45.59%;S:5.07%;T:50.66% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=197.402 Mem=2048 Cpu=U:40.53%;S:5.07%;T:45.59% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=187.554 Mem=2048 Cpu=U:42.65%;S:5.33%;T:47.99% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=181.838 Mem=2048 Cpu=U:44.00%;S:5.50%;T:49.49% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=204.391 Mem=2048 Cpu=U:44.03%;S:9.79%;T:53.82% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=198.261 Mem=2048 Cpu=U:40.35%;S:10.09%;T:50.44% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=213.622 Mem=2048 Cpu=U:42.13%;S:4.68%;T:46.81% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=197.825 Mem=2048 Cpu=U:45.49%;S:10.11%;T:55.60% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=202.137 Mem=2048 Cpu=U:39.58%;S:9.89%;T:49.47% [www] 127.0.0.1 - 21/Jul/2016:14:17:30 +0800 "GET /index.php" 200 .... Time=221.151 Mem=2048 Cpu=U:36.17%;S:4.52%;T:40.70% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=168.815 Mem=2048 Cpu=U:53.31%;S:5.92%;T:59.24% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=168.277 Mem=2048 Cpu=U:47.54%;S:5.94%;T:53.48% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=184.290 Mem=2048 Cpu=U:48.84%;S:5.43%;T:54.26% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=166.918 Mem=2048 Cpu=U:47.93%;S:5.99%;T:53.92% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=159.977 Mem=2048 Cpu=U:50.01%;S:12.50%;T:62.51% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=209.724 Mem=2048 Cpu=U:42.91%;S:9.54%;T:52.45% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=186.367 Mem=2048 Cpu=U:42.93%;S:5.37%;T:48.29% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=171.344 Mem=2048 Cpu=U:40.85%;S:5.84%;T:46.69% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=195.746 Mem=2048 Cpu=U:45.98%;S:10.22%;T:56.20% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=179.811 Mem=2048 Cpu=U:44.49%;S:5.56%;T:50.05% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=159.584 Mem=2048 Cpu=U:50.13%;S:6.27%;T:56.40% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=141.376 Mem=2048 Cpu=U:56.59%;S:7.07%;T:63.66% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=152.181 Mem=2048 Cpu=U:52.57%;S:13.14%;T:65.71% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=148.747 Mem=2048 Cpu=U:53.78%;S:6.72%;T:60.51% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=188.122 Mem=2048 Cpu=U:42.53%;S:10.63%;T:53.16% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=222.400 Mem=2048 Cpu=U:35.97%;S:4.50%;T:40.47% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=234.064 Mem=2048 Cpu=U:34.18%;S:4.27%;T:38.45% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=223.316 Mem=2048 Cpu=U:35.82%;S:4.48%;T:40.30% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=204.123 Mem=2048 Cpu=U:44.09%;S:4.90%;T:48.99% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=185.770 Mem=2048 Cpu=U:48.45%;S:10.77%;T:59.21% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=178.269 Mem=2048 Cpu=U:44.88%;S:5.61%;T:50.49% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=181.095 Mem=2048 Cpu=U:49.70%;S:5.52%;T:55.22% [www] 127.0.0.1 - 21/Jul/2016:14:17:31 +0800 "GET /index.php" 200 .... Time=151.841 Mem=2048 Cpu=U:52.69%;S:13.17%;T:65.86% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=169.613 Mem=2048 Cpu=U:47.17%;S:5.90%;T:53.06% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=150.290 Mem=2048 Cpu=U:46.58%;S:13.31%;T:59.88% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=166.815 Mem=2048 Cpu=U:47.96%;S:5.99%;T:53.95% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=136.843 Mem=2048 Cpu=U:58.46%;S:7.31%;T:65.77% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=152.656 Mem=2048 Cpu=U:52.41%;S:6.55%;T:58.96% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=159.144 Mem=2048 Cpu=U:50.27%;S:6.28%;T:56.55% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=143.945 Mem=2048 Cpu=U:55.58%;S:6.95%;T:62.52% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=134.992 Mem=2048 Cpu=U:59.26%;S:7.41%;T:66.67% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=152.695 Mem=2048 Cpu=U:52.39%;S:13.10%;T:65.49% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=165.980 Mem=2048 Cpu=U:48.20%;S:6.02%;T:54.22% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=171.853 Mem=2048 Cpu=U:46.55%;S:11.64%;T:58.19% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=168.789 Mem=2048 Cpu=U:53.32%;S:5.92%;T:59.25% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=180.222 Mem=2048 Cpu=U:44.39%;S:5.55%;T:49.94% [www] 127.0.0.1 - 21/Jul/2016:14:17:32 +0800 "GET /index.php" 200 .... Time=182.382 Mem=2048 Cpu=U:43.86%;S:5.48%;T:49.35% |
ab测试结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
Server Software: nginx Server Hostname: laravel.local.com Server Port: 80 Document Path: / Document Length: 931 bytes Concurrency Level: 10 Time taken for tests: 27.875 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 1925992 bytes HTML transferred: 931000 bytes Requests per second: 35.87 [#/sec] (mean) Time per request: 278.749 [ms] (mean) Time per request: 27.875 [ms] (mean, across all concurrent requests) Transfer rate: 67.47 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 2 Processing: 132 278 135.5 243 1567 Waiting: 132 277 135.5 243 1567 Total: 132 278 135.5 243 1568 Percentage of the requests served within a certain time (ms) 50% 243 66% 262 75% 282 80% 293 90% 335 95% 403 98% 923 99% 1025 100% 1568 (longest request) |
下面是Phalcon的情况,好很多:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
[www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=4.111 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.479 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.865 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.603 Mem=2048 Cpu=U:384.17%;S:384.17%;T:768.34% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.067 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=8.258 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.115 Mem=2048 Cpu=U:472.81%;S:0.00%;T:472.81% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.189 Mem=2048 Cpu=U:0.00%;S:313.58%;T:313.58% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.294 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.292 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.368 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.529 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.221 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.906 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.189 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=33.383 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.497 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.297 Mem=2048 Cpu=U:303.31%;S:0.00%;T:303.31% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.331 Mem=2048 Cpu=U:429.00%;S:0.00%;T:429.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.449 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.523 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.122 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.195 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.485 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.301 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=7.716 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.246 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.277 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.305 Mem=2048 Cpu=U:433.84%;S:0.00%;T:433.84% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.765 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.710 Mem=2048 Cpu=U:369.00%;S:0.00%;T:369.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.351 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.089 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.865 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.790 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=8.027 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.194 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.403 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.082 Mem=2048 Cpu=U:480.31%;S:0.00%;T:480.31% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=6.163 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.388 Mem=2048 Cpu=U:418.76%;S:0.00%;T:418.76% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.055 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=3.302 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.130 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.650 Mem=2048 Cpu=U:377.36%;S:0.00%;T:377.36% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.067 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=4.741 Mem=2048 Cpu=U:210.93%;S:210.93%;T:421.85% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.180 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.362 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% [www] 127.0.0.1 - 21/Jul/2016:14:43:19 +0800 "GET /index.php" 200 .... Time=2.348 Mem=2048 Cpu=U:0.00%;S:0.00%;T:0.00% |
ab测试的结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
Server Software: nginx Server Hostname: phalcon.local.com Server Port: 80 Document Path: / Document Length: 775 bytes Concurrency Level: 10 Time taken for tests: 1.555 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 953000 bytes HTML transferred: 775000 bytes Requests per second: 642.89 [#/sec] (mean) Time per request: 15.555 [ms] (mean) Time per request: 1.555 [ms] (mean, across all concurrent requests) Transfer rate: 598.32 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.5 0 7 Processing: 7 15 6.7 13 66 Waiting: 7 15 6.6 13 66 Total: 7 15 6.6 13 66 Percentage of the requests served within a certain time (ms) 50% 13 66% 15 75% 17 80% 19 90% 22 95% 27 98% 35 99% 45 100% 66 (longest request) |
cassandra 启动异常一例
2016-05-16今天在两个机器上分别安装和更新cassandra 2.x,发现居然启动不了了。没有日志,没有信息,死活搞不定。
后来还是在 hub.docker 的cassandra的Dockerfile里面看到了解决方案:
1 2 |
# https://issues.apache.org/jira/browse/CASSANDRA-11661 RUN sed -ri 's/^(JVM_PATCH_VERSION)=.*/\1=25/' /etc/cassandra/cassandra-env.sh |
有空没空看看Dockerfile还是蛮有用滴~
转载:Redis和Memcached的区别
2016-04-26全文分享:标点符的《Redis和Memcached的区别》
Redis的作者Salvatore Sanfilippo曾经对这两种基于内存的数据存储系统进行过比较:
- Redis支持服务器端的数据操作:Redis相比Memcached来说,拥有更多的数据结构和并支持更丰富的数据操作,通常在Memcached里,你需要将数据拿到客户端来进行类似的修改再set回去。这大大增加了网络IO的次数和数据体积。在Redis中,这些复杂的操作通常和一般的GET/SET一样高效。所以,如果需要缓存能够支持更复杂的结构和操作,那么Redis会是不错的选择。
- 内存使用效率对比:使用简单的key-value存储的话,Memcached的内存利用率更高,而如果Redis采用hash结构来做key-value存储,由于其组合式的压缩,其内存利用率会高于Memcached。
- 性能对比:由于Redis只使用单核,而Memcached可以使用多核,所以平均每一个核上Redis在存储小数据时比Memcached性能更高。而在100k以上的数据中,Memcached性能要高于Redis,虽然Redis最近也在存储大数据的性能上进行优化,但是比起Memcached,还是稍有逊色。
我也一直比较模糊到底什么时候用memcached,什么时候适合redis。redis功能各方面都很优秀,从维护、复用、多功能角度,一般情况下用个redis就可以了。通过上面对比,我觉得,redis还是更适合数据cache,memcached做页面cache,这样可能更好点:)
ubuntu下面安装部署kong
2016-04-25
1 2 |
deb http://www.apache.org/dist/cassandra/debian 22x main deb-src http://www.apache.org/dist/cassandra/debian 22x main |
1 2 |
gpg --keyserver pgp.mit.edu --recv-keys F758CE318D77295D gpg --export --armor F758CE318D77295D | sudo apt-key add - |
1 |
W: GPG error: http://www.apache.org 22x InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 749D6EEC0353B12C |
1 2 |
gpg --keyserver pgp.mit.edu --recv-keys 2B5C1B00 gpg --export --armor 2B5C1B00 | sudo apt-key add - |
1 2 |
gpg --keyserver pgp.mit.edu --recv-keys 0353B12C gpg --export --armor 0353B12C | sudo apt-key add - |
1 2 |
sudo apt-get update sudo apt-get install cassandra |
1 2 3 |
sudo apt-get update sudo apt-get install netcat openssl libpcre3 dnsmasq procps sudo dpkg -i kong-0.8.0.*.deb |
Kong – 好玩的东西,api网关
2016-04-22Kong可以说是API的得力助手。对需要从事API管理的广大开发员来说,它是最出色的工具之一。Kong是开源工具,具有可扩展性和模块性,可以在任何一种基础设施上运行。多年来,Kong一直在支持优秀的开发项目,比如Mashape(世界上规模最大的API市场)。最棒的是,Kong得到了强大的Nginx的支持。
Kong的主要功能
– Kong可灵活扩展:只要增添更多的服务器实例,它就能横向扩展,毫无问题,那样你可以支持更多流量,同时确保网络延迟很短。
– Kong可在任何地方运行:它可以部署在单个或多个数据中心环境的私有云或公有云上。它还支持大多数流行的操作系统,比如Linux、Mac和Windows。Kong包括许多实用技巧,以便针对大多数现代平台完成安装和配置工作。
– Kong具有模块性:它可以与新的插件协同运行,扩展基本功能。可将你的API与许多不同的插件整合起来,以增强安全、分析、验证、日志及/或监测机制。最好的例子之一就是Nginx Plus插件(https://getkong.org/plugins/nginx-plus-monitoring/),该插件提供了服务器实时监测机制,以获得关于负载和请求的度量指标和统计数字。
– 开源及企业:虽然Kong是开源工具,可供每个人免费使用,但你也能获得企业版,企业版通过电子邮件、电话和聊天提供了快速支持,此外还提供初始安装、从第三方API管理工具来迁移、紧急补丁、热修复程序及更多特性。
同一台电脑配置/关联/使用两个或多个Github账号
2016-03-19传送门:http://www.iwwenbo.com/a-pc-many-githubs/
遇到的坑:
用Mac自带的ssh作为日常ssh客户端,我在~/.ssh/config中做了如下配置,以避免开多个tab登录同一个远程的时候,反复输入认证信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# # git.oschina.net # Host git.oschina.net HostName git.oschina.net IdentityFile ~/.ssh/id_rsa Host xueron.oschina.net HostName git.oschina.net IdentityFile ~/.ssh/id_rsa_xueron ...... # # 通用配置 # Host * ServerAliveCountMax 3 ServerAliveInterval 10 ControlMaster auto ControlPath ~/.ssh/%h-%p-%r ControlPersist yes |
这里ControlPath是记录已登录会话,并且复用的。这里 %h-%p-%r 是生成的一个socket的文件名,%h代表实际远程的hostname,%p是远程主机的端口,%r是登录远程主机的用户名。由于上述两个git帐号的设置,这几个参数是一样的,所以登录多个git帐号无效。
小小的改动是增加一个%n,也就是同时记录本地别名,区分一下即可:
1 2 3 4 5 6 |
Host * ServerAliveCountMax 3 ServerAliveInterval 10 ControlMaster auto ControlPath ~/.ssh/%n-%h-%p-%r ControlPersist yes |
PhalconPHP and PHP7
2016-03-16From: http://phalcon.io/phalconphp-and-php7
PHP7 was released on the 3rd of December, 2015. This new version brought forward a large number of new and exiting features (http://php.net/manual/en/migration70.new-features.php) to PHP. Perhaps one of the biggest of the new features is a new Zend Engine (the engine that powers PHP).
This new engine, code named PHPNG, will give some of your applications double the performance speed.
Some benchmarks that have been run so far:
WordPress 3.6 – 20.0% gain (253 vs 211 req/sec)
Drupal 6.1 – 11.7% gain (1770 vs 1585 req/sec)
Qdig – 15.3% gain (555 vs 482 req/sec)
ZF test app – 30.5% gain (217 vs 166 req/sec)
It is only natural that once it came out the PhalconPHP community was dying to know when we would get a chance to work with PhalconPHP and PHP7.
The Problem
We all know that PhalconPHP is written in Zephir starting with version 2.0, and that this language compiles its code into a C PHP Extension. Because of PHP7’s new engine the extension had to be rewritten and adapted to the new specifications.
The Solution
Knowing this, the PhalconPHP team started working since last year on an updated version of Zephir to make the compiled code work with PHP7.
After a few months we are finally delivered PhalconPHP 2.1 and Zephir 0.9.x which brings PHP7 support.
Installing PhalconPHP with PHP7
You will need to install PHP7+ and Zephir 0.9.2a-dev (or its latest branch). After you have them installed go to PhalconPHP 2.1.0+ branch and download the source code.
Installation example:
1 2 |
root@localhost:~$ cd cphalcon-2.1.x/ root@localhost:~/cphalcon-2.1.x$ zephir build —backend=ZendEngine3 |
If you get these warnings ignore them:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
Warning: Variable "_SESSION" assigned but not used in Phalcon\Session\Adapter::remove in /root/cphalcon-2.1.x/phalcon/session/adapter.zep on 204 [unused-variable] } -^ Warning: Variable "beforeLine" assigned but not used in Phalcon\Debug::showTraceItem in /root/cphalcon-2.1.x/phalcon/debug.zep on 339 [unused-variable] beforeLine, firstLine, afterLine, lastLine, i, linePosition, currentLine; -------------^ Warning: Variable "possibleSetter" declared but not used in Phalcon\Mvc\Model::assign in /root/cphalcon-2.1.x/phalcon/mvc/model.zep on 440 [unused-variable] var key, keyMapped, value, attribute, attributeField, possibleSetter, metaData, columnMap, dataMapped; ----------------------------------------------------------------------^ Warning: Function "\\sodium\\randombytes_buf" does not exist at compile time in /root/cphalcon-2.1.x/phalcon/security/random.zep on 119 [nonexistent-function] return \\Sodium\\randombytes_buf(len); ----------------------------------------^ Warning: Function "\\sodium\\randombytes_uniform" does not exist at compile time in /root/cphalcon-2.1.x/phalcon/security/random.zep on 310 [nonexistent-function] return \\Sodium\\randombytes_uniform(len); --------------------------------------------^ Compiling... Installing... Extension installed! Don't forget to restart your web server root@localhost:~/cphalcon-2.1.x$ service php-fpm restart |
That’s it!
You now have PhalconPHP and PHP7 working.
Can you expect PhalconPHP to be even faster? No, but you can expect to see your your app be much faster since your PHP code will run better with the new engine. Plus, you won’t have any overhead since PhalconPHP is a extension. The best part of all this is that you get all the new features that PHP7 brings to the table.
Do take into account that PHP7 is still rather new, and most of the commonly used extensions like memcache, memcached, and redis are available in Dev/Beta branches, so you need to reinstall them.
Best of luck to all and enjoy PhalconPHP + PHP7.
百度真特么给力啊!
2016-03-14搜索一个『深证证券交易所』,都能让那么多山寨、啃爹货放在头条,几乎是需要翻页才能找到正版。