Git Product home page Git Product logo

请教一个问题:微信支付,我如果只初始化一个全局Client实例,在处理不同请求的时候会不会有并发瓶颈?(比如同时有1000人下单,会不会有阻塞的情况) about gopay HOT 5 CLOSED

go-pay avatar go-pay commented on May 18, 2024
请教一个问题:微信支付,我如果只初始化一个全局Client实例,在处理不同请求的时候会不会有并发瓶颈?(比如同时有1000人下单,会不会有阻塞的情况)

from gopay.

Comments (5)

iGoogle-ink avatar iGoogle-ink commented on May 18, 2024 3

@zhangbo0724
客户端请求的锁是 读写锁,而且只加的读锁,以防在读的时候被改掉,读锁的性能很高的,这点暂时还不用担心
还有一点很重要的,加锁只是在 读一些参数时做的,真正发起请求,锁已经释放了,刚处理优化过这个问题
image

from gopay.

llgoer avatar llgoer commented on May 18, 2024

客户端请求的时候是带锁的,一个处理完处理另外一个,同时下单会阻塞

from gopay.

zhangbo0724 avatar zhangbo0724 commented on May 18, 2024

真实应用场景的时候肯定会有并发的需求,如果是同步执行的话就弱化了SDK的功能。只所以只实例化一个Client实例,是为了针对需要证书的请求时,避免频繁加载证书,但是单实例又会遇到并发的问题。希望后续可以完善SDK,考虑并发的场景。谢谢!

from gopay.

llgoer avatar llgoer commented on May 18, 2024

没必要担心这个问题,一次请求本身就挺快的了,1000人同时支付,你这业务量真大

from gopay.

fwhezfwhez avatar fwhezfwhez commented on May 18, 2024

为啥要加锁,看不明白。
只有存在竞态的业务,才需要锁。

支付的sdk,很显然,所有业务都不是竞态的。

代码的架构上,还是有一点问题的

from gopay.

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.