The document discusses generators, fibers, and coroutines in PHP. It explains that generators allow for yielding values iteratively without building an array, while fibers provide each their own call stack allowing suspension at any point. Coroutines in Swoole make blocking I/O non-blocking through automatic yielding and resuming. Event loops power asynchronous non-blocking I/O by handling callbacks from I/O streams. Both generators and fibers are building blocks for implementing coroutines to improve PHP application concurrency.
"Swoole: double troubles in c", Alexandr VronskiyFwdays
Practices in using Swoole ecosystem & migration real production marketplace app to async approach. Which benefits we got and what problems happens on stack with PHP8, Postgresql, Redis, RebbitMQ, Doctrine, coroutines/fibers, concurrency HTTP Server.
Let's dive under the hood of Java network applications. We plan to have a deep look to classic sockets and NIO having live coding examples. Then we discuss performance problems of sockets and find out how NIO can help us to handle 10000+ connections in a single thread. And finally we learn how to build high load application server using Netty.
https://github.com/kslisenko/java-networking
Slides from a presentation given at Laravel Chicago on November 18, 2014. Goes over the basics of building a REST API using the Laravel framework as well as some handy tips and tools.
24시간 365일 서비스를 위한 MySQL DB 이중화.
MySQL 이중화 방안들에 대해 알아보고 운영하면서 겪은 고민들을 이야기해 봅니다.
목차
1. DB 이중화 필요성
2. 이중화 방안
- HW 이중화
- MySQL Replication 이중화
3. 이중화 운영 장애
4. DNS와 VIP
5. MySQL 이중화 솔루션 비교
대상
- MySQL을 서비스하고 있는 인프라 담당자
- MySQL 이중화에 관심 있는 개발자
Let's get into several common types of queries that developers struggle with, showing SQL solutions, and then analyze them for optimal efficiency. I'll cover Exclusion Join, Random Selection, Greatest-Per-Group, Dynamic Pivot, and Relational Division.
With PHP 7.2 recently released and PHP 5.3 and 5.4 still accounting for over 40% of all production environments, it's time to paint a clear picture on not just why everyone should move to 7.0 (or preferably 7.1), but on how to get code ready for the latest version of PHP.
Using the version compatibility checker for PHP_CodeSniffer and a few simple step-by-step instructions, upgrading old code to make it compatible with the latest PHP versions becomes actually really easy. In this talk, we'll migrate an old piece of code and get rid of the demons of the past and ready for the present and future.
Dead-Simple Async Control Flow with CoroutinesTravis Kaufman
Coroutines are extremely powerful constructs that make writing asynchronous code dead simple. In this talk, we'll go over how we can implement coroutines in ES2015 using generators and promises, as well as tools and libraries that allow you to leverage coroutines today. We'll also walk through some sample use cases that showcase the power of coroutines.
Example code is available at https://github.com/traviskaufman/co-talk-examples
"Swoole: double troubles in c", Alexandr VronskiyFwdays
Practices in using Swoole ecosystem & migration real production marketplace app to async approach. Which benefits we got and what problems happens on stack with PHP8, Postgresql, Redis, RebbitMQ, Doctrine, coroutines/fibers, concurrency HTTP Server.
Let's dive under the hood of Java network applications. We plan to have a deep look to classic sockets and NIO having live coding examples. Then we discuss performance problems of sockets and find out how NIO can help us to handle 10000+ connections in a single thread. And finally we learn how to build high load application server using Netty.
https://github.com/kslisenko/java-networking
Slides from a presentation given at Laravel Chicago on November 18, 2014. Goes over the basics of building a REST API using the Laravel framework as well as some handy tips and tools.
24시간 365일 서비스를 위한 MySQL DB 이중화.
MySQL 이중화 방안들에 대해 알아보고 운영하면서 겪은 고민들을 이야기해 봅니다.
목차
1. DB 이중화 필요성
2. 이중화 방안
- HW 이중화
- MySQL Replication 이중화
3. 이중화 운영 장애
4. DNS와 VIP
5. MySQL 이중화 솔루션 비교
대상
- MySQL을 서비스하고 있는 인프라 담당자
- MySQL 이중화에 관심 있는 개발자
Let's get into several common types of queries that developers struggle with, showing SQL solutions, and then analyze them for optimal efficiency. I'll cover Exclusion Join, Random Selection, Greatest-Per-Group, Dynamic Pivot, and Relational Division.
With PHP 7.2 recently released and PHP 5.3 and 5.4 still accounting for over 40% of all production environments, it's time to paint a clear picture on not just why everyone should move to 7.0 (or preferably 7.1), but on how to get code ready for the latest version of PHP.
Using the version compatibility checker for PHP_CodeSniffer and a few simple step-by-step instructions, upgrading old code to make it compatible with the latest PHP versions becomes actually really easy. In this talk, we'll migrate an old piece of code and get rid of the demons of the past and ready for the present and future.
Dead-Simple Async Control Flow with CoroutinesTravis Kaufman
Coroutines are extremely powerful constructs that make writing asynchronous code dead simple. In this talk, we'll go over how we can implement coroutines in ES2015 using generators and promises, as well as tools and libraries that allow you to leverage coroutines today. We'll also walk through some sample use cases that showcase the power of coroutines.
Example code is available at https://github.com/traviskaufman/co-talk-examples
A one hour tutorial on daily work enhancements provided by the PHP debugging extension Xdebug.
Attention: This is a pre-release of the raw slides used in the presentation. A condensed version, including screeshots, might follow later.
With PHP 8.0 recently released and PHP 5.x still accounting for over 40% of all production environments, it's time to paint a clear picture on not just why everyone should move to 8.x, but on how to get code ready for the latest version of PHP. In this talk, we'll look at some handy tools and techniques to ease the migration.
In this presentation you are going to learn about basics of Web and php mysql web development. we discover about What is world wide web? How client server works? Why PHP is important? and basics of PHP like installation, variables, operators, conditional statements and loops.
rqlite - replicating SQLite via Raft consensuPhilip O'Toole
rqlite is a distributed, replicated, relational database that uses SQLite as its storage engine. This presentation was give at the San Francisco Go Meetup in April 2016.
Want to learn how Facebook scales their load balancing infrastructure to support more than 1.3 billion users? We will be revealing the technologies and methods we use to global route and balance Facebook's traffic. The Traffic team at Facebook has built several systems for managing and balancing our site traffic, including both a DNS load balancer and a software load balancer capable of handling several protocols. This talk will focus on these technologies and how they have helped improve user performance, manage capacity, and increase reliability.
ApacheCon 2021: Apache NiFi 101- introduction and best practicesTimothy Spann
ApacheCon 2021: Apache NiFi 101- introduction and best practices
Thursday 14:10 UTC
Apache NiFi 101: Introduction and Best Practices
Timothy Spann
In this talk, we will walk step by step through Apache NiFi from the first load to first application. I will include slides, articles and examples to take away as a Quick Start to utilizing Apache NiFi in your real-time dataflows. I will help you get up and running locally on your laptop, Docker
DZone Zone Leader and Big Data MVB
@PaasDev
https://github.com/tspannhw https://www.datainmotion.dev/
https://github.com/tspannhw/SpeakerProfile
https://dev.to/tspannhw
https://sessionize.com/tspann/
https://www.slideshare.net/bunkertor
A lot of people use Docker/rkt, but very often we do not have time to actually understand how they work. So today in half-hour I will show you in a nutshell how that works. My hope is that even after you know how to build a container engine, I can still convince you that the existing tools are worth spending $MM to create and use.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
From Generator to Fiber the Road to Coroutine in PHP
1. From Generator to Fiber
The Road to Coroutine
in PHP
@COSCUP 2022
Albert Chen
2. 02 Blocking and Async I/O in PHP
Outline
01 I/O Models in Linux
03 What is Generator?
04 What is Fiber in PHP 8.1?
05 How to Use Async I/O with Coroutine?
07 Q&A
06 Coroutines in Swoole
4. I/O Models in Linux
Synchronous Blocking I/O
(https://developer.ibm.com/articles/l-async)
5. I/O Models in Linux
Synchronous Non-Blocking I/O
(https://developer.ibm.com/articles/l-async)
6. I/O Models in Linux
Asynchronous Blocking I/O
(https://developer.ibm.com/articles/l-async)
7. I/O Models in Linux
Asynchronous Non-Blocking I/O
(https://developer.ibm.com/articles/l-async)
8. I/O Models in Linux
Comparison of the I/O Models
(https://rickhw.github.io/2019/02/27/ComputerScience/IO-Models)
9. Blocking I/O in PHP
All I/O functions in PHP are born to be synchronous
Easy for developers to understand
Less-efficient for utilization of CPU usage
11. 1s worker
1s worker
1s worker
Blocking I/O in PHP
If one request takes 1s in I/O waiting
Each worker can handle only one request and the same time
Concurrency in PHP depends on worker numbers
Context switch between processes are expensive!
request
request
request
12. Asynchronous I/O in PHP
The simplest but worst-performant solution in PHP
spatie/async package (needs pcntl and posix extensions)
13. Asynchronous I/O in PHP
The simplest but worst-performant solution in PHP
spatie/async package (needs pcntl and posix extensions)
worker
process process
fork
fork
18. Asynchronous I/O in PHP
Async I/O Extensions in PHP
ext-event: libevent wrapper
ext-ev: libev wrapper
ext-uv: libuv wrapper
Both ReactPHP and Amp support these extensions as
event-loop drivers
19. select poll epoll
Data
Structue
Array Linked List
Red–Black
Tree
Big O O(n) O(n) O(log(n))
FD Limit
1024 (x86)
2048 (x64)
Unlimited Unlimited
Asynchronous I/O in PHP
I/O Multiplexing in Linux
20. Asynchronous I/O in PHP
I/O Multiplexing in Linux
(http://daemonforums.org/showthread.php?t=2124)
24. Generator
Supported since PHP 5.5
Generator provides an easy way to implement simple iterators
Generator allows you to write code that uses foreach to iterate over
a set of data without needing to build an array in memory
Generator can yield as many times as it needs to provide the values
to be iterated over
(From official PHP manual)
25. Generator
Reading large file with Generator
Regular Version Generator Version
(https://clouding.city/php/generator)
26. Generator
Generators, also known as semi-coroutines, are a subset of
coroutines
Coroutines can control where execution continues immediately
after they yield, while Generators cannot, instead transferring
control back to the generator's caller
The yield statement in a generator does not specify a coroutine
to jump to, but rather passes a value back to a parent routine
A PHP based Coroutine Scheduler needs to implemented for
stackful coroutine
(From Wikipedia)
28. Generator
Two Way Data Transfer in Generator
?
(https://www.npopov.com/2012/12/22/Cooperative-multitasking-using-coroutines-in-PHP.html)
29. Generator
Two Way Data Transfer in Generator
yield1
ret1
yield2
ret2
NULL
the first var_dump in gen
the var_dump of the send()
again from within gen
the return value of send()
(https://www.npopov.com/2012/12/22/Cooperative-multitasking-using-coroutines-in-PHP.html)
36. Generator
Both ReactPHP and Amp use Promise and Generator for Coroutine
Generators
yield promise
Event Loop
Coroutines
subscribe
send/throw
37. Fiber
New feature in PHP 8.1
Submitted and developed by Amp
Unlike stackless Generators, each Fiber has its own call stack,
allowing them to be paused within deeply nested function calls
Execution may be interrupted anywhere in the call stack using
Fiber::suspend()
Once suspended, execution of the fiber may be resumed with any
value using Fiber::resume()
(From official PHP manual)
41. Fiber
Basic Usage
fiber start
fiber suspend
fiber continue
done
the first echo in fiber
value from fiber suspend
value from fiber resume
end message
54. Fiber
Both ReactPHP and amp(v3 beta) support Fiber now
A comprehensive coroutine rather than semi-coroutine
Eliminates yield statement for coroutines
Fiber doesn't turn your code into Non-Blocking magically, traditional
blocking code has to be rewritten with asynchronous I/O
Help not too much for most of developers
Fiber provides only bare minimum required to allow user code to
implement full-stack coroutines in PHP
Fiber doesn't support Preemptive Scheduling yet
66. Coroutine in Swoole
Channel
[coroutine 3]
int(0)
[coroutine 2] - 0
[coroutine 3]
int(1)
[coroutine 2] - 1
[coroutine 3]
......
second coroutine
second coroutine
second coroutine
popped value
popped value
first coroutine
first coroutine
67. Coroutine in Swoole
Swoole implements its full coroutine features
Built-in Blocking I/O functions can be replaced to Non-Blocking I/O
automatically if hook flags are set
Swoole supports Preemptive Scheduling for CPU-bound tasks
Swoole Provides CSP Model for Coroutine Communications like in
GoLang
Yields and resumes take place behind the scenes for I/O functions
switching
68. Questions
What's the difference between Asynchronous and Coroutine?
What's the difference between Generator and Fiber?
How to turn Blocking I/O stream turning into Non-Blocking?
What is Event Loop? Is it required for Asynchronous?
What's the benefits of Coroutine?
Is Asynchronous a must for Coroutine?
How to make built-in Blocking I/O functions Asynchronous?
Can Asynchronous I/O be integrated with traditional Blocking I/O
environment? (e.g. PHP-FPM)