Comments (5)
It's QPS is 192K, throughput is 750Mb/s. I'd like to update it into my data sheet.
I'm not an expert here, please correct me if I'm wrong. So typescript is the project name and nodejs is the language? And what is its concurrency modle ? Coroutine ? Async callback ?
from photonlibos.
Sure, Node.js is a runtime which uses Chrome V8 engine to allow JavaScript to execute on server.
It provides API's for interacting with network/filesystem etc.
TypeScript is a type-system for JavaScript -- it gets removed at runtime, and compiled into JavaScript.
TypeScript code (with types) --> transpile --> JavaScript code --> Node.js runs JS code --> executes on V8 C++ engine
- https://github.com/nodejs/node
Node.js is an open-source, cross-platform JavaScript runtime environment.
- https://v8.dev/
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js,
- https://github.com/microsoft/TypeScript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
I mostly use TypeScript as it makes the code easier to read/maintain,
It has no performance impact and disappears after compiling👍
And what is its concurrency modle ? Coroutine ? Async callback ?
It is async callback, the low-level net
package in Node.js has event-listeners which fire callback functions when operations happen like data received
, socket opened
, connection acquired
etc.
The server code is tiny, it just echos back out what it received:
function server() {
const server = net.createServer()
server.on("connection", (socket) => {
socket.on("data", (data) => {
console.count("server received ops")
socket.write(data)
})
})
server.listen(flags.PORT, flags.IP, () => {
console.log(`server listening on ${flags.IP}:${flags.PORT}`)
})
}
And then the callbacks are registered when the ClientSocket
class is created here:
(I made some notes in comments below, for instance right now a static buffer is allocated, I'm not sure if this is supposed to be re-allocated every time)
class ClientSocket {
// Should this be re-allocated every operation?
// If so, this needs to be removed, see <---- down below
private static buf: Buffer = Buffer.alloc(flags.BUF_SIZE)
constructor() {
this.socket = new net.Socket()
this.sentOpsTotal = 0
this.receivedOpsTotal = 0
this.sentBytesTotal = 0
this.receivedBytesTotal = 0
this.lastOpStartTime = performance.timeOrigin
}
// Handlers for what should happen when data is received are registered as callbacks here
async connect() {
return new Promise((resolve, reject) => {
this.socket.connect(flags.PORT, flags.IP, () => {
resolve(this)
})
this.socket.on("data", (data) => {
this.receivedOpsTotal++
this.receivedBytesTotal += data.length
// this.socket.write(Buffer.alloc(flags.BUF_SIZE)) <------
this.socket.write(ClientSocket.buf)
this.sentOpsTotal++
this.sentBytesTotal += data.length
this.lastOpStartTime = performance.now()
})
this.socket.on("error", (err) => {
reject(err)
})
})
}
}
from photonlibos.
I was using my own client to test against your server, in order to reduce variables.
from photonlibos.
Oh LOL, that makes a more sense doesn't it?
You may want to try commenting out this line
console.count("server received ops")
And see if it makes any difference btw
from photonlibos.
Closed for #97
from photonlibos.
Related Issues (20)
- What is 'randomizer' in thread_create for? HOT 2
- install option via cmake? HOT 3
- Issue building on Ubuntu/ARM HOT 11
- [Discussion] Add ENABLE_TLS option HOT 2
- Build fails on fresh Ubuntu 23.04, GCC-13 HOT 11
- Pinning Photon vcpu to specific cpu cores HOT 5
- It would be great if it supports various clients, such as grpc, redis, mysql.. HOT 5
- - HOT 1
- Thread-per-core Architecture HOT 18
- Windows IOCP backend support HOT 4
- EPOLL: Why not set EPOLLONESHOT in add_interest when ONESHOT is set? HOT 4
- Scalable Stack Discuss HOT 4
- Clarification on Lock and Synchronization HOT 19
- build with curl 8.2.1 failed, some macros are deprecated.
- Unit test with lockfree queue `PhotonLockfreeBatchMPMCQueue+Batch` reported mismatch.
- Example for RDMA HOT 2
- TLS implementation does not validate certificate chain HOT 2
- Will it support system API hooks in the future? For example, sleep, connect, recv, etc. HOT 2
- Support customized UserAgent in Http HOT 1
- examples/perf/io-perf fails with segmentation fault with io-uring: HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from photonlibos.