Giter Site home page Giter Site logo

Comments (4)

zqzjz0911 avatar zqzjz0911 commented on May 30, 2024

直接使用 openresty 的 ngx_lua 模块的 ngx.shared_dict 就可以做缓存了啊。

from nginx-openresty-windows.

zqzjz0911 avatar zqzjz0911 commented on May 30, 2024

userdata 不可以,lua 的 shared_dict 只支持 这几种类型的数据存储,number,boolean,string,所以最好的解决方法就是把 你的 userdata 序列化成一个字符串,然后传入,取出的时候再反序列化出来。

from nginx-openresty-windows.

foxericlee1 avatar foxericlee1 commented on May 30, 2024

Hi zqzjz0911:
首先非常感谢你的热心回复。我将c中的指针转为字符串后传入lua,并保存到shared_dict。但是跨越不同http request,这个指针是无效的。当然,一个http request中可以运行。所以,我估计,即使将worker设置为1个,在每次http request中,都有不同的堆栈和运行环境。同时,我认为以目前情况,openresty很难做到有状态的大数据量计算任务(例如在内存中的拓扑分析,先要建立拓扑结构,然后根据拓扑改变再计算。拓扑不是每次http request请求时重新建立的,数据量高达几十G),我本打算将openresty应用到这种场景中,但我还没有找到这样的方案。使用redis固然是一种办法,但序列化->存储->反序列化的过程耗时太长。不知道有大拿能够有办法没有。
最后说一下,在没有办法的情况下,我选择了FastCGI技术,然后用C++实现了数据缓存和计算的部分。前端使用Openrest做无状态、简单查询、交易类的命。重度计算则由openresty转到fastcgi执行。

from nginx-openresty-windows.

zqzjz0911 avatar zqzjz0911 commented on May 30, 2024

序列化指针会引起问题的,序列化整个对象才能跨进程,这样有状态的请求也是可以处理。可以考虑一下哈。

from nginx-openresty-windows.

Related Issues (20)

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.