我们在我们的app服务器上运行PHP堆栈,它在本地使用twemproxy(通过套接字),连接到我们的缓存层的多个上游memcached服务器(EC2小实例).
我经常从应用监视器收到一个警告,即页面加载时间大于5秒.发生这种情况时,立即修复是在每个应用服务器上重新启动twemproxy服务,这是一个麻烦.
我现在唯一的解决方案是每分钟运行一次crontab并重新启动服务,但是你可以想象每分钟都没有写几秒钟,这不是一个理想的永久解决方案.
有没有人遇到过这个?如果是这样,修复了什么?我尝试切换到AWS Elasticache但它没有与我们当前的twemproxy解决方案相同的性能.
这是我的twemproxy配置.
default:
auto_eject_hosts: true
distribution: ketama
hash: fnv1a_64
listen: /var/run/nutcracker/nutcracker.sock 0666
server_failure_limit: 1
server_retry_timeout: 600000 # 600sec, 10m
timeout: 100
servers:
- vcache-1:11211:1
- vcache-2:11211:1
Run Code Online (Sandbox Code Playgroud)
这是php层的连接配置:
# Note: We are using HA / twemproxy (nutcracker) / memcached proxy
# So this isn't a default memcache(d) port
# Each webapp will host the cache proxy, which allows us to connect via socket
# which should be faster, as no tcp overhead
# Hash has been manually …
Run Code Online (Sandbox Code Playgroud) 我有一个事务表,其中可以存储多个行对三个属性(foo_id,bar_id),最后一个属性是deleted_at,这里的想法是确保我一次只有一个活动行(deleted_at ='0000-00 -00 00:00:00').
但是我收到以下错误:
mysql> UPDATE epic_table SET deleted_at = NOW() WHERE (foo_id = '1' AND bar_id IN ('18'));
ERROR 1062 (23000): Duplicate entry '18-1-2015-08-08 16:35:46' for key 'epic_table_ibuk_1'
Run Code Online (Sandbox Code Playgroud)
这是架构:
CREATE TABLE `epic_table` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`foo_id` bigint(20) unsigned NOT NULL,
`bar_id` bigint(20) unsigned NOT NULL,
`created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`deleted_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY `epic_table_ibuk_1` (`foo_id`,`bar_id`,`deleted_at`),
KEY `epic_table_ibfk_1` (`foo_id`),
KEY `epic_table_ibfk_2` (`bar_id`),
CONSTRAINT `epic_table_ibfk_1` …
Run Code Online (Sandbox Code Playgroud) 目前正在开发一个项目,将我们的Goole Maps API从v2升级到v3并遇到问题,需要确认是否可以将多个侦听器注册到同一个标记.任何人都可以确认Goole Maps API v3是否支持API v2等同一标记上的多个侦听器?
示例代码:
var mapObject = document.getElementById('map_canvas');
var points = new Array();
var markers = new Array();
var mapOptions = {
zoom: 16,
center: new google.maps.LatLng(33.260081, -117.279369),
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
draggable: true,
scaleControl: false,
zoomControl: true,
panControl: true,
scrollwheel: false,
disableDoubleClickZoom: false,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.ZOOM_PAN
}
map = new google.maps.Map(mapObject, mapOptions);
points.push(lat:'33.260081', lng:'-117.279369');
points.push(lat:'33.260079', lng:'-117.279371');
points.push(lat:'33.260083', lng:'-117.279373');
for (var i in points) {
var point = points[i];
var marker = initMarker(point);
markers.push(marker);
google.maps.event.addListener(marker, …
Run Code Online (Sandbox Code Playgroud) 所以我正在编写一个ant buildfile,它将在cruisecontrol中使用并遇到一个奇怪的问题.我用Google搜索了问题,但没有遇到任何具体的解决方案,所以我想我会在这里发布问题.
我有以下蚂蚁任务:
<target name="module.lint">
<apply executable="/usr/bin/php" failonerror="true">
<arg value="-l" />
<fileset dir="/path/to/my/elite/code" includes="**/*.php" />
</apply>
</target>
Run Code Online (Sandbox Code Playgroud)
当我使用以下方式运行它:
ant -buildfile /path/to/my/elite/buildfiles/project/elite/build.xml module.lint
Run Code Online (Sandbox Code Playgroud)
它运行正常,但当我尝试通过CruiseControl GUI构建项目时,我收到以下错误:
[cc]Aug-09 15:51:04 ScriptRunner - fileset: Setup scanner in dir /path/to/my/elite/code with patternSet{ includes: [**/*.php] excludes: [] }
[cc]Aug-09 15:51:04 ScriptRunner - [apply] Executing '/usr/bin/php' with arguments:
[cc]Aug-09 15:51:04 ScriptRunner - [apply] '-l'
[cc]Aug-09 15:51:04 ScriptRunner - [apply] '/path/to/my/elite/code/Script.php'
[cc]Aug-09 15:51:04 ScriptRunner - [apply]
[cc]Aug-09 15:51:04 ScriptRunner - [apply] The ' characters around the executable and arguments …
Run Code Online (Sandbox Code Playgroud) 如标题所述,我正在尝试通过href URL给定的PHP脚本下载一个文件,该文件带有相关的mime类型,然后重新加载同一页面,但还不太清楚,这是我到目前为止的内容:
<a id="viewAttachmentLink" href="/path/to/script.php?id=123">View Attachment</a>
<script type='text/javascript'>
jquery('#viewAttachmentLink').bind('click', function() {
if (myFunction()) {
window.location.href = "jquery(this).attr('href')";
setTimeout(location.reload(), 400);
} else {
return false;
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
使用此代码,它将重新加载页面,但似乎没有调用PHP脚本。
任何人都有在 AWS 上实施 NFS 的合理策略,使其不是 SPoF(单点故障),或者至少在实例崩溃时能够快速恢复?
我读过这篇SO post,与与多个 EC2 实例共享文件的能力有关,但它没有回答如何确保 HA 与 AWS 上的 NFS 的问题,只是可以使用 NFS。
很多网上资产都说AWS EFS可用,但它仍处于预览模式,仅在俄勒冈地区可用,我们的主要VPC位于加利福尼亚州北部,因此无法使用此选项。
其他在线资产说GlusterFS是一种方法,但经过一些研究,由于竞争条件和性能问题,我对实施此解决方案感到不舒服。
另一种选择是SoftNAS,但我想避免将未知的 AMI 带入严格控制的同类环境中。
这留下了NFS。NFS 是我们在开发环境中使用的并且运行良好,但它是开发环境,所以如果它崩溃,我们会在系统修复问题时喝几杯啤酒,但在生产环境中,这显然是不行的。
目前我能想到的最佳解决方案是创建一个 EBS 和两个 EC2 实例。两个实例都将照常更新(通过 puppet)以保持堆栈对齐(内核、nfs 库等),但只有一个实例会挂载 EBS。我们在活动 NFS 实例上设置了一个监视器,如果它出现故障,我们会收到通知,我们手动分离并附加到备份 EC2 实例。我想我们还创建了一个也可以删除/重新连接的网络接口,因此我们只需要在 DNS 中维护一个 IP。
尽管我认为我们可以使用 keepalived 自动执行此操作,以及允许自动分离/重新连接的 IAM 策略。
- 更新 -
看起来 EBS 卷与特定可用区相关联,因此无法重新附加到另一个可用区中的实例。我能想到的唯一其他选择是:
这里唯一的问题是,保持两个 NFS …
试着这样做:
# nodes.pp
node 'dev-a-1.sn1.vpc1.example.com' inherits project_j1n_sn1_vpc1_dev {
class { 'custom::core':
overrides => {
'openssh' => {'settings' => {'external_access' => 'true'}}, # Allow direct mounting for dev
'rsyslog' => {'settings' => {'role' => 'node', 'filters' => {'php' => {'target' => 'remote'}, 'mail' => {'target' => 'remote'}}}}
}
}
}
# custom::core
class custom::core($overrides = {}) {
if (has_key($overrides, 'openssh')) {
$settings = $overrides['openssh']['settings']
# Doesn't work
create_resources('openssh', $settings)
# Doesn't work
class { 'openssh': $settings }
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以调用一个类并传递一个哈希作为参数?
Puppet/Puppetmaster …
我能够让我的应用程序通过SFSafariViewController按照这篇文章自动加载一个URL ,并且效果很好,唯一的缺点就是导航栏.
当以这种方式使用时,SFSafariViewController导航栏是无用的,因为url是只读的,并且'done'链接除了重新加载页面之外什么都不做.因此,我想完全隐藏导航栏.
根据附加到已接受答案的注释,建议将我的根视图控制器设置为SFSafariViewController,这是我无法工作的.设置很简单,因为有一个视图控制器,代码包含在上述帖子中.
如何隐藏导航栏但仍然保留SFSafariViewController的好处?或者,如果我无法隐藏导航栏,至少隐藏"完成"链接?
代码段:
import UIKit
import SafariServices
class ViewController: UIViewController
{
private var urlString:String = "https://example.com"
override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(animated: Bool)
{
super.viewDidAppear(animated)
let svc = SFSafariViewController(URL: NSURL(string: self.urlString)!)
self.presentViewController(svc, animated: true, completion: nil)
self.navigationItem.rightBarButtonItem = nil
}
override func didReceiveMemoryWarning()
{
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud)
-----工作.Navbar是"隐藏的"-----
import UIKit …
Run Code Online (Sandbox Code Playgroud) 因此,我正在编写一个 bash 脚本来清除临时文件,但遇到了无法解释的行为。
# Find using mmin flag
find /usr/local/store/file/temp/3_day/ -mmin +$((60*24*3)) -type f > /tmp/old_files_by_mmin.txt
# Find using mtime flag
find /usr/local/store/file/temp/3_day/ -mtime +3 -type f > /tmp/old_files_by_mtime.txt
diff -u /tmp/old_files_by_mmin.txt /tmp/old_files_by_mtime.txt
Run Code Online (Sandbox Code Playgroud)
前几行:
--- /tmp/old_files_by_mmin.txt 2016-08-03 16:56:42.535458820 +0000
+++ /tmp/old_files_by_mtime.txt 2016-08-03 16:56:58.310681524 +0000
@@ -117,59 +117,6 @@
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/15/36/1296924350
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/47/52/1950191632
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/30/01/711250694
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/44313759
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/1589177813
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/1189074525
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/56/44/91382315
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/09/43/45/1622776054
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/44/57/1465920226
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/23/17/1467026748
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/15/58/1990201487
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/13/19/1990298215
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/35/59/518813467
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/10/53/1962045410
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/31/27/290517373
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/05/08/547481306
Run Code Online (Sandbox Code Playgroud)
为什么 -mmin 标志拾取 mtime 标志没有拾取的文件?如果两者都应该找到比现在 + 3 天更旧的文件?
通过setcookie()
和设置cookie之间有什么区别$_COOKIE
吗?
有时,当设置cookie时setcookie
,我没有通过$ _COOKIE ['cookie_name']获得该cookie的值.但是js console.log之后立即setcookie
显示cookie已设置但是如果我试图获取该值的值cookie通过$ _COOKIE,我没有得到更新的值.
我糊涂了..!!