我有一个涉及的设置
前端服务器(Node.js,domain:localhost:3000)<--->后端(Django,Ajax,域:localhost:8000)
浏览器< - webapp < - Node.js(服务应用)
浏览器(webapp) - > Ajax - > Django(服务ajax POST请求)
现在,我的问题在于CORS设置,webapp使用它来向后端服务器进行Ajax调用.在chrome中,我一直在努力
当credentials标志为true时,无法在Access-Control-Allow-Origin中使用通配符.
在Firefox上也不起作用.
我的Node.js设置是:
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', 'http://localhost:8000/');
res.header('Access-Control-Allow-Credentials', true);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
};
Run Code Online (Sandbox Code Playgroud)
webapp发出如下请求:
$.ajax({
type: "POST",
url: 'http://localhost:8000/blah',
data: {},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json',
success: successHandler
});
Run Code Online (Sandbox Code Playgroud)
因此,webapp发送的请求标头如下所示:
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: "Origin, X-Requested-With, Content-Type, Accept"
Access-Control-Allow-Methods: 'GET,PUT,POST,DELETE'
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: …
Run Code Online (Sandbox Code Playgroud) 我有以下设置:
omg/telperion
docker hub上的docker 镜像一个kubernetes集群(有4个节点,每个节点有~50GB RAM)和充足的资源
我按照教程将图像从dockerhub拉到kubernetes
SERVICE_NAME=telperion
DOCKER_SERVER="https://index.docker.io/v1/"
DOCKER_USERNAME=username
DOCKER_PASSWORD=password
DOCKER_EMAIL="omg@whatever.com"
# Create secret
kubectl create secret docker-registry dockerhub --docker-server=$DOCKER_SERVER --docker-username=$DOCKER_USERNAME --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL
# Create service yaml
echo "apiVersion: v1 \n\
kind: Pod \n\
metadata: \n\
name: ${SERVICE_NAME} \n\
spec: \n\
containers: \n\
- name: ${SERVICE_NAME} \n\
image: omg/${SERVICE_NAME} \n\
imagePullPolicy: Always \n\
command: [ \"echo\",\"done deploying $SERVICE_NAME\" ] \n\
imagePullSecrets: \n\
- name: dockerhub" > $SERVICE_NAME.yaml
# Deploy to kubernetes
kubectl create -f $SERVICE_NAME.yaml
Run Code Online (Sandbox Code Playgroud)
这导致pod进入了 CrashLoopBackoff
docker run …
我正在尝试在数据集的样本上使用高斯混合模型.我使用了两个MLlib
(带pyspark
)和scikit-learn
得到非常不同的结果,scikit-learn
一个看起来更逼真.
from pyspark.mllib.clustering import GaussianMixture as SparkGaussianMixture
from sklearn.mixture import GaussianMixture
from pyspark.mllib.linalg import Vectors
Run Code Online (Sandbox Code Playgroud)
Scikit-learn:
local = pd.DataFrame([ x.asDict() for x in df.sample(0.0001).collect() ])
model1 = GaussianMixture(n_components=3)
model1.fit([ [x] for x in local['field'].tolist() ])
model1.means_
array([[7.56123598e+00],
[1.32517410e+07],
[3.96762639e+04]])
model1.covariances_
array([[[6.65177423e+00]],
[[1.00000000e-06]],
[[8.38380897e+10]]])
Run Code Online (Sandbox Code Playgroud)
MLLib:
model2 = SparkGaussianMixture.train(
sc.createDataFrame(local).rdd.map(lambda x: Vectors.dense(x.field)),
k=3,
convergenceTol=1e-4,
maxIterations=100
)
model2.gaussians
[MultivariateGaussian(mu=DenseVector([28736.5113]), sigma=DenseMatrix(1, 1, [1094083795.0001], 0)),
MultivariateGaussian(mu=DenseVector([7839059.9208]), sigma=DenseMatrix(1, 1, [38775218707109.83], 0)),
MultivariateGaussian(mu=DenseVector([43.8723]), sigma=DenseMatrix(1, 1, [608204.4711], 0))] …
Run Code Online (Sandbox Code Playgroud) v8是否对单个对象的堆分配有限制?
a = new Array(1024*1024*102)
在节点命令行上失败
FATAL ERROR: JS Allocation failed - process out of memory
此外,当作为脚本运行时,这会失败并出现相同的错误
node --expose-gc --nouse-idle-notification --max-old-space-size=8192
FATAL ERROR: CALL_AND_RETRY_0 Allocation failed - process out of memory
var util = require('util');
o = {};
while(1) {
o["hahahahahaha" + String(ctr)] = ctr;
ctr++;
if (ctr % 100000 === 0) {
console.log(util.inspect(process.memoryUsage()));
if (ctr % 10000000 === 0) gc();
}
}
Run Code Online (Sandbox Code Playgroud)
最后输出:
{ rss: 1009557504, heapTotal: 993408824, heapUsed: 964980592 }
然而,
var a = [];
while(1) {
var …
Run Code Online (Sandbox Code Playgroud) node.js ×2
ajax ×1
apache-spark ×1
bash ×1
cors ×1
django ×1
docker ×1
javascript ×1
kubernetes ×1
pyspark ×1
python ×1
scikit-learn ×1
v8 ×1