Code Monkey home page Code Monkey logo

pike's Introduction

pike

Build Status

与varnish类似的HTTP缓存服务器,主要的特性如下:

  • 提供WEB的管理配置界面,简单易上手
  • 支持br与gzip两种压缩方式,根据客户端自动选择。对于可缓存与不可缓存请求使用不同的压缩配置,更佳的时间与空间的平衡
  • 仅基于Cache-Control生成缓存有效期,接口缓存完全由接口开发者决定,准确而高效(开发比运维更清楚接口是否可缓存,可缓存时长)
  • 配置支持文件与etcd两种形式存储,无中断的配置实时更新
  • 支持H2C的转发,提升与后端服务的调用性能(如果是内网转发,不需要启用)
  • 与upstream的调用支持gzipbrotlilz4snappy以及zstd压缩,可根据与upstream的网络线路选择合适的压缩方式
  • 支持upstream检测失败时回调告警,可及时获取异常upstream信息
  • 支持自定义日志,可配置按日期与大小分割日志并压缩
  • LUR与持久化存储(可选)配合使用,可根据内存使用选择更小的LRU缓存并增加持久化存储的方式
  • 持久化存储支持以下形式:badger(文件)、redis以及mongodb

启动方式

启动参数主要如下:

  • config 配置保存地址,可以指定为etcd或者本地文件,如:etcd://user:[email protected]:2379/pike,本地文件:/opt/pike/config.yml
  • admin 配置管理后台的访问地址,如:--admin=:9013
  • log 日志文件目录,支持单文件与lumberjack形式,如/var/pike.loglumberjack:///tmp/pike.log?maxSize=100&maxAge=1&compress=true,lumberjack会根据文件内容大小与时间将文件分割

使用文件保存配置

# linux etcd,管理后台使用9013端口访问
./pike --config=etcd://127.0.0.1:2379/pike --admin=:9013
# linux file,配置文件保存在/opt/pike.yml,管理后台使用9013端口访问
./pike --config=/opt/pike.yml --admin=:9013

# docker
docker run -it --rm \
    -p 9013:9013 \
    vicanso/pike:4.0.0-alpha --config=etcd://172.16.183.177:2379/pike --admin=:9013

TODO

  • 缓存查询(如果缓存量较大,有可能导致查询性能较差,暂时未支持)

pike's People

Contributors

dependabot[bot] avatar vicanso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pike's Issues

打不开管理主页

版本
v4.1.0 windows x64

启动命令 :
.\pike.exe --admin=:9013

访问 127.0.0.1:9013 出现错误:

{"statusCode":500,"category":"elton-error","message":"open web\index.html: file does not exist","exception":true}

增加对brotli压缩的支持

根据HTTP请求头中的:Accept-Encoding:gzip, deflate, br,对于支持brotli压缩的客户端,使用br压缩返回。

Potential import collision: import path should be "gopkg.in/yaml.v2", not "github.com/go-yaml/yaml".

Background

The go-yaml/yaml has already renamed it’s import path from "github.com/go-yaml/yaml" to "gopkg.in/yaml.v2".
As README of go-yaml/yaml v2.1.0 said, downstream repos should use "gopkg.in/yaml.v2" to get or import go-yaml/yaml.

Example
Some more examples can be found in the "examples" folder.

package main
import (
        "fmt"
        "log"
        "gopkg.in/yaml.v2"
)
…

But vicanso/pike still used the old path:
https://github.com/vicanso/pike/blob/master/go.mod#L10

github.com/go-yaml/yaml v2.1.0+incompatible 

When you use the old path "github.com/go-yaml/yaml" to import the go-yaml/yaml, it will be very easy to reintroduce go-yaml/yaml through the import statements "import gopkg.in/yaml.v2" in the go source file of go-yaml/yaml.
https://github.com/go-yaml/yaml/blob/v2.1.0/decode_test.go#L12

package yaml_test
import (
	…
	. "gopkg.in/check.v1"
	"gopkg.in/yaml.v2"
)

The "gopkg.in/yaml.v2" and "github.com/go-yaml/yaml" are the same repos. This will work in isolation, bring about potential risks and problems.

Solution

Replace all the old import paths, change "github.com/go-yaml/yaml" to "gopkg.in/yaml.v2".
Where did you import it: https://github.com/vicanso/pike/search?q=github.com%2Fgo-yaml%2Fyaml&unscoped_q=github.com%2Fgo-yaml%2Fyaml

增加对图片智能转换至webp

根据响应的Content-Type以及客户端的请求头Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,选择更优的webp图片格式

NFR : group cashing

First of all want to admire your project. Its the best and most complex opensource cashing software out there. Keep the good work!

Second i like to propose several new new feature requests and if possible to discus them (from what i see form the code you have impressive knowledge about http protocol specially in the optimization aspect)

First proposal is about several instances that use a distributed cache:
Ref : https://github.com/golang/groupcache

Second is related to abstraction of the upstreams.
To be able to handle GCS or S3 buckets as upstream

Third one is for UI : options to display some statistics like miss/hit ratio and ability to purge cache entries.

And documentation is a bit foggy Took me about a 3 days to run the app with my scenario but at the end results are impressive !

日志文件在那里

{remote} {when-iso} {:proxyTarget} {method} {uri} {proto} {status} {size-human} {referer} {userAgent}
从那里面能看到日志,好像没有产生新文件

如何配置某个url缓存多长时间

1、如何配置某个url缓存多长时间
2、能否根据参数配置缓存的key,比如参数是 a=1&b=2&c=3&d=4 其中c和d参数都无用,只想根据a b参数缓存
3、能否根据resp header判断是否缓存,缓存多长时间(varnish支持)

docker 按照官网手册运行不成功

image

image

image

docker run -d --restart=always -p 3015:3015 -v ./config.yml:/etc/pike/config.yml vicanso/pike
不知道是不是我服务器的问题。。 docker映射目录一定要绝对路径吧。。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.