Skip to content

Instantly share code, notes, and snippets.

@WeixinX
Created October 17, 2023 03:18
Show Gist options
  • Save WeixinX/c24f4ded37832dd7e753b2d27470f0fc to your computer and use it in GitHub Desktop.
Save WeixinX/c24f4ded37832dd7e753b2d27470f0fc to your computer and use it in GitHub Desktop.
Higress Transformer vs Spring Cloud Gateway
# test reqeust:
# "http://<SCG-IP>:<Port>/response-headers?X-Test-Dedupe=1&X-Test-Dedupe=2&X-Test-Dedupe=3&X-Test-Dedupe=4&testKey=1&testKey=2&testKey=4&testKey=4" \
# -H 'X-Header-From: 1' -H 'X-Header-From: 2' -H 'X-Header-From: 3' -H 'X-Header-From: 4'
spring:
application:
name: scg
cloud:
nacos:
discovery:
server-addr: xxx.xxx.xxx.xxx:8848
gateway:
routes:
- id: test_route
uri: lb://httpbin-svc
predicates:
- Path=/**
filters:
- AddRequestHeader=X-Header-1, 1
- AddRequestHeader=X-Header-2, 2
- AddRequestHeader=X-Header-3, 3
- AddRequestHeader=X-Header-4, 4
- DedupeResponseHeader=X-Test-Dedupe, RETAIN_FIRST
- MapRequestHeader=X-Header-From, X-Header-To
- RemoveRequestParameter=testKey
server:
port: 18085
# test request:
# "http://<Higress-Gateway-IP>:<Port>/response-headers?X-Test-Dedupe=1&X-Test-Dedupe=2&X-Test-Dedupe=3&X-Test-Dedupe=4&testKey=1&testKey=2&testKey=4&testKey=4" \
# -H 'X-Header-From: 1' -H 'X-Header-From: 2' -H 'X-Header-From: 3' -H 'X-Header-From: 4'
type: request
rules:
- operate: remove
querys:
- key: testKey
- operate: add
headers:
- key: X-Header-1
value: 1
- key: X-Header-2
value: 2
- key: X-Header-3
value: 3
- key: X-Header-4
value: 4
- operate: map
headers:
- key: X-Header-From
value: X-Header-To
---
type: response
rules:
- operate: dedupe
headers:
- key: X-Test-Dedupe
value: RETAIN_FIRST
#!/bin/bash
PID=$1
FILE_NAME="result-$PID.csv"
echo "%CPU,%MEM,RES" > $FILE_NAME
for (( i = 0; i < 120; i++ )) do
# The positions of %CPU, %MEM, and RES may be different,
# adjusted according to the actual situation.
res=`top -n 1 -p $PID | awk '{ if (NR == 8) { printf "%.2f,%.2f,%.2f", $10, $11, $7 } }'`
echo "$res" >> $FILE_NAME
echo "$res"
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment