SlideShare una empresa de Scribd logo
1 de 18
Webonise Lab
PHP – Session Handling Using
Memcached
PHP – Session

“A method to maintain state of user on Server.”
Session are more like cookies, however there state is maintained
on server. When we start session, session id is stored in cookie
on client side. This session ID inked client to a particular file or
record depending upon how session is started
PHP – Session
Session
Storage

There are multiple ways of handling session in PHP. They are as follows
1. File
2. Relation Database
3. Distributed Caching
FILES

The “Files” session handler in PHP is default session save handler.
It stores session data as files on disk, in a specified directory (or sometimes in
a tree of directories). Usually, this save handler is capable of easily handling
tens of thousands of sessions.

The biggest disadvantage of the files save handler is that it imposes a major
scalability bottleneck when trying to scale an application to run on more than
one server.
Relation
Database

Relation Database is another way to handle session and save it. In this type,
the session and it related data is stored in DB table.
To achieve this, we have to crate a table which will store the session id, host
name and the data.
When ever, client requests for session data, a query will get executed and user
and data will be fetched from database
This way of session handling solves the scalability problem but involved some
major drawback too
Relation
Database

1. Performance
2. Memory
3. Server Failure Handling issue
Memcached

What is Memcached?
–

Memcached (pronounced as ‘mem-cache-D’) is an

open-source

distributed memory based storage system, designed mostly as a fast
caching solution.
–

It is invented by Brad Fitzpatrick
Memcached
Use the following commands for the installations:

Memcached is mainly developed as caching mechanism for distributed sever.
The memcached has proved itself as one of the best caching mechanism in
recent years.
Worlds most highly traffic websites use memcache as there performance
booster. Eg. Facebook
Memcached
Use the following commands for the installations:

The advantages of Memcached are as follows
1. Performance
2. Scalability
3. Easy Installation
Session +
Memcache
Use the following commands for the installations:

Lets see how this equation works for PHP
Session Storage in memcached solves the locality problem, and is usually faster
than most DB session storage implementations.
Memcached is distributed in the sense that data may be spread on multiple
nodes – this makes memcached scalable when it
growing number of concurrent sessions.

comes to handling a
Installation
Installation of memcached is very easy. Follow the following steps to
install memcache in server
STEP #1
sudo apt-get update
sudo apt-get install memcached
Above will install memcached in your linux machine.
Installation
STEP #2 – Installing PHP memcache etension
sudo apt-get install memcahe
OR
sudo apt-get install php5-memcache

Above commands will install memcache extension for PHP. It is available on
PECL
Configurations
Don't open champagne yet. We have to make some configuration in PHP to
have party.
Following are the steps to make configuration
STEP #1
Open your php.ini file and change session save handler. It is by default as
“files”. Change as below
session.save_handler = memcache
STEP #2
Change the session save path
session.save_path = “tcp://hostIP:11211”
Configurations
To handle session using memcache on web cluster (multiserver architecture),
All we need to add another server as comma separated in session save path

session.save_path = “tcp://hostIP:11211, tcp://AnotherHostIP:11211”
In above it is important that both the server should have Memcached installed
and it should allow your server IP to store memcache. To do so we have to
make changes in /etc/memcached.conf file.
Here you will see the “-l 127.0.0.1” as default which mean, only local can save
the memcache. Here you need to add the server IP which you want to allow
FLOW
DONE!
At last we are Done with installation and configuration of PHP. Now its
time to test it

Let's have demo of all the efforts
Thank You!

Más contenido relacionado

La actualidad más candente

Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...elliando dias
 
Overview of the ehcache
Overview of the ehcacheOverview of the ehcache
Overview of the ehcacheHyeonSeok Choi
 
Ehcache Architecture, Features And Usage Patterns
Ehcache Architecture, Features And Usage PatternsEhcache Architecture, Features And Usage Patterns
Ehcache Architecture, Features And Usage PatternsEduardo Pelegri-Llopart
 
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusionAdvanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusionColdFusionConference
 
Distributed Caching Essential Lessons (Ts 1402)
Distributed Caching   Essential Lessons (Ts 1402)Distributed Caching   Essential Lessons (Ts 1402)
Distributed Caching Essential Lessons (Ts 1402)Yury Kaliaha
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web CacheProdigyView
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetAchieve Internet
 
World Wide Web Caching
World Wide Web CachingWorld Wide Web Caching
World Wide Web Cachingersanbilik
 
Implementing High Availability Caching with Memcached
Implementing High Availability Caching with MemcachedImplementing High Availability Caching with Memcached
Implementing High Availability Caching with MemcachedGear6
 
[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching SolutionsITviec
 
Drupal performance optimization Best Practices
Drupal performance optimization Best PracticesDrupal performance optimization Best Practices
Drupal performance optimization Best PracticesRatnesh kumar, CSM
 
Postgres on OpenStack
Postgres on OpenStackPostgres on OpenStack
Postgres on OpenStackEDB
 
Tsm7.1 seminar Stavanger
Tsm7.1 seminar StavangerTsm7.1 seminar Stavanger
Tsm7.1 seminar StavangerSolv AS
 
Ehcache3 — JSR-107 on steroids
Ehcache3 — JSR-107 on steroidsEhcache3 — JSR-107 on steroids
Ehcache3 — JSR-107 on steroidsAlex Snaps
 
Planning & Best Practice for Microsoft Virtualization
Planning & Best Practice for Microsoft VirtualizationPlanning & Best Practice for Microsoft Virtualization
Planning & Best Practice for Microsoft VirtualizationLai Yoong Seng
 
MongoDB performance
MongoDB performanceMongoDB performance
MongoDB performanceMydbops
 
Aioug connection poolsizingconcepts
Aioug connection poolsizingconceptsAioug connection poolsizingconcepts
Aioug connection poolsizingconceptsToon Koppelaars
 

La actualidad más candente (20)

Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
 
Overview of the ehcache
Overview of the ehcacheOverview of the ehcache
Overview of the ehcache
 
Ehcache Architecture, Features And Usage Patterns
Ehcache Architecture, Features And Usage PatternsEhcache Architecture, Features And Usage Patterns
Ehcache Architecture, Features And Usage Patterns
 
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusionAdvanced caching techniques with ehcache, big memory, terracotta, and coldfusion
Advanced caching techniques with ehcache, big memory, terracotta, and coldfusion
 
Distributed Caching Essential Lessons (Ts 1402)
Distributed Caching   Essential Lessons (Ts 1402)Distributed Caching   Essential Lessons (Ts 1402)
Distributed Caching Essential Lessons (Ts 1402)
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web Cache
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
 
5 Reasons to Upgrade Ehcache to BigMemory Go
5 Reasons to Upgrade Ehcache to BigMemory Go5 Reasons to Upgrade Ehcache to BigMemory Go
5 Reasons to Upgrade Ehcache to BigMemory Go
 
World Wide Web Caching
World Wide Web CachingWorld Wide Web Caching
World Wide Web Caching
 
Caching
CachingCaching
Caching
 
Implementing High Availability Caching with Memcached
Implementing High Availability Caching with MemcachedImplementing High Availability Caching with Memcached
Implementing High Availability Caching with Memcached
 
[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions
 
Drupal performance optimization Best Practices
Drupal performance optimization Best PracticesDrupal performance optimization Best Practices
Drupal performance optimization Best Practices
 
Postgres on OpenStack
Postgres on OpenStackPostgres on OpenStack
Postgres on OpenStack
 
Tsm7.1 seminar Stavanger
Tsm7.1 seminar StavangerTsm7.1 seminar Stavanger
Tsm7.1 seminar Stavanger
 
Cassandra as Memcache
Cassandra as MemcacheCassandra as Memcache
Cassandra as Memcache
 
Ehcache3 — JSR-107 on steroids
Ehcache3 — JSR-107 on steroidsEhcache3 — JSR-107 on steroids
Ehcache3 — JSR-107 on steroids
 
Planning & Best Practice for Microsoft Virtualization
Planning & Best Practice for Microsoft VirtualizationPlanning & Best Practice for Microsoft Virtualization
Planning & Best Practice for Microsoft Virtualization
 
MongoDB performance
MongoDB performanceMongoDB performance
MongoDB performance
 
Aioug connection poolsizingconcepts
Aioug connection poolsizingconceptsAioug connection poolsizingconcepts
Aioug connection poolsizingconcepts
 

Similar a Session Handling Using Memcache

phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialWim Godden
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Wim Godden
 
Achieving Massive Scalability and High Availability for PHP Applications in t...
Achieving Massive Scalability and High Availability for PHP Applications in t...Achieving Massive Scalability and High Availability for PHP Applications in t...
Achieving Massive Scalability and High Availability for PHP Applications in t...RightScale
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Wim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheGive Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheBen Ramsey
 
Caching objects-in-memory
Caching objects-in-memoryCaching objects-in-memory
Caching objects-in-memoryMauro Cassani
 
Optimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend ServerOptimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend Servervarien
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetAchieve Internet
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Memcached B box presentation
Memcached B box presentationMemcached B box presentation
Memcached B box presentationNagesh Chinkeri
 
Lamp Stack Optimization
Lamp Stack OptimizationLamp Stack Optimization
Lamp Stack OptimizationDave Ross
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
PHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsPHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsSven Rautenberg
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...ColdFusionConference
 
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Shailendra Prasad
 

Similar a Session Handling Using Memcache (20)

phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
 
Achieving Massive Scalability and High Availability for PHP Applications in t...
Achieving Massive Scalability and High Availability for PHP Applications in t...Achieving Massive Scalability and High Availability for PHP Applications in t...
Achieving Massive Scalability and High Availability for PHP Applications in t...
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Drupal7 MEMCACHE
Drupal7 MEMCACHE Drupal7 MEMCACHE
Drupal7 MEMCACHE
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheGive Your Site a Boost with Memcache
Give Your Site a Boost with Memcache
 
Caching objects-in-memory
Caching objects-in-memoryCaching objects-in-memory
Caching objects-in-memory
 
Php myadmin
Php myadminPhp myadmin
Php myadmin
 
Optimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend ServerOptimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend Server
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Memcached B box presentation
Memcached B box presentationMemcached B box presentation
Memcached B box presentation
 
Lamp Stack Optimization
Lamp Stack OptimizationLamp Stack Optimization
Lamp Stack Optimization
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
PHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsPHP Sessions and Non-Sessions
PHP Sessions and Non-Sessions
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...
 
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Session Handling Using Memcache

  • 1. Webonise Lab PHP – Session Handling Using Memcached
  • 2. PHP – Session “A method to maintain state of user on Server.” Session are more like cookies, however there state is maintained on server. When we start session, session id is stored in cookie on client side. This session ID inked client to a particular file or record depending upon how session is started
  • 4. Session Storage There are multiple ways of handling session in PHP. They are as follows 1. File 2. Relation Database 3. Distributed Caching
  • 5. FILES The “Files” session handler in PHP is default session save handler. It stores session data as files on disk, in a specified directory (or sometimes in a tree of directories). Usually, this save handler is capable of easily handling tens of thousands of sessions. The biggest disadvantage of the files save handler is that it imposes a major scalability bottleneck when trying to scale an application to run on more than one server.
  • 6. Relation Database Relation Database is another way to handle session and save it. In this type, the session and it related data is stored in DB table. To achieve this, we have to crate a table which will store the session id, host name and the data. When ever, client requests for session data, a query will get executed and user and data will be fetched from database This way of session handling solves the scalability problem but involved some major drawback too
  • 7. Relation Database 1. Performance 2. Memory 3. Server Failure Handling issue
  • 8. Memcached What is Memcached? – Memcached (pronounced as ‘mem-cache-D’) is an open-source distributed memory based storage system, designed mostly as a fast caching solution. – It is invented by Brad Fitzpatrick
  • 9. Memcached Use the following commands for the installations: Memcached is mainly developed as caching mechanism for distributed sever. The memcached has proved itself as one of the best caching mechanism in recent years. Worlds most highly traffic websites use memcache as there performance booster. Eg. Facebook
  • 10. Memcached Use the following commands for the installations: The advantages of Memcached are as follows 1. Performance 2. Scalability 3. Easy Installation
  • 11. Session + Memcache Use the following commands for the installations: Lets see how this equation works for PHP Session Storage in memcached solves the locality problem, and is usually faster than most DB session storage implementations. Memcached is distributed in the sense that data may be spread on multiple nodes – this makes memcached scalable when it growing number of concurrent sessions. comes to handling a
  • 12. Installation Installation of memcached is very easy. Follow the following steps to install memcache in server STEP #1 sudo apt-get update sudo apt-get install memcached Above will install memcached in your linux machine.
  • 13. Installation STEP #2 – Installing PHP memcache etension sudo apt-get install memcahe OR sudo apt-get install php5-memcache Above commands will install memcache extension for PHP. It is available on PECL
  • 14. Configurations Don't open champagne yet. We have to make some configuration in PHP to have party. Following are the steps to make configuration STEP #1 Open your php.ini file and change session save handler. It is by default as “files”. Change as below session.save_handler = memcache STEP #2 Change the session save path session.save_path = “tcp://hostIP:11211”
  • 15. Configurations To handle session using memcache on web cluster (multiserver architecture), All we need to add another server as comma separated in session save path session.save_path = “tcp://hostIP:11211, tcp://AnotherHostIP:11211” In above it is important that both the server should have Memcached installed and it should allow your server IP to store memcache. To do so we have to make changes in /etc/memcached.conf file. Here you will see the “-l 127.0.0.1” as default which mean, only local can save the memcache. Here you need to add the server IP which you want to allow
  • 16. FLOW
  • 17. DONE! At last we are Done with installation and configuration of PHP. Now its time to test it Let's have demo of all the efforts