Git Product home page Git Product logo

Comments (7)

lukeewu avatar lukeewu commented on July 20, 2024

from seckill.

wenbochang888 avatar wenbochang888 commented on July 20, 2024

@lukeewu

` public String execute() {

	long num = redis.opsForValue().increment(key, -1);
	if (num <= 0) {
		return "秒杀失败";
	} else {
		//入队
		mq.send(new HappyLock(key, Integer.parseInt(num + "")));
	}
	return "";
}`

如上代码
假设有10w个请求,但商品数量只有100件(或者更多)。我redis预减少,屏蔽掉了9.9k个无效请求(if else那里判断了一下),难道mysql还处理不了这100个请求么?

from seckill.

lukeewu avatar lukeewu commented on July 20, 2024

from seckill.

wenbochang888 avatar wenbochang888 commented on July 20, 2024

@lukeewu
hahah,小米那个另当别论哈

你只是100个,假如是0.00001秒来了一百个,那么。。。

我想问下这个什么意思呢?我测试了好多遍,上面那段代码并不会出现超卖现象

from seckill.

lukeewu avatar lukeewu commented on July 20, 2024

from seckill.

wenbochang888 avatar wenbochang888 commented on July 20, 2024

@lukeewu

mysql依然要在0.000001秒内接收到100次请求

哈哈哈,这个还是很有难度的。
我用的是jmeter测试的,一秒模拟了1w了线程,没有出现问题。
还有待讨论,感谢你的回答

from seckill.

lukeewu avatar lukeewu commented on July 20, 2024

from seckill.

Related Issues (4)

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.