전 포스팅에서 한번 언급한 바가 있지만, 고도몰에 접속하거나 토큰에 의해서 데이터를 가져오게 되는 경우 Session 연결을 성립하게 되는 경우다.

 

Android 단에서 ApiService.kt 단에서 GET method 방식으로 Shop의 User Profile 을 확인하는 부분을 추가시켜 주었고, 원래라면 앱이 켜졌을 때마다 accessToken 을 가지고 고도몰에 대해서 End-Point 단위로 request 를 날려주려 했으나 비효율적이라는 판단이 들은 것 같다.

 

1.

앱을 사용하는 사용자들이 전부다 샵을 이용할 계획이 있는 것은 아니기 때문이다.

이러한 부분에서 앱을 키자마자 무조건적으로 샵에 대해서 request 를 전송하게 되면, 불필요한 트래픽과 동시에 request 가 발생하게 된다.

 

2.

WebView 에 의해서 Shop 이 로드됫을 때 (init) 시점마다 request 를 던져주게 되면, 자연스럽게 WebView 안에 있는 Web 에 대해서도 Session Handling 을 할 수 있게 되기 때문에 이 부분이 구조적으로 볼 때에 정상적이라고 볼 수 있을 것 같았다.

 

여하튼 패치 후, 정상적으로 세션 끊김 문제는 해결되었고

 Signed Key를 이용하여 Deploy 를 하기위해 Android Market 에 검토요청을 올렸다.

 

기존의 BitBucket 에서 ssh-key 를 등록할 때, Personal Setting 을 하던 부분에서 약간의 변동사항이 생겼다.

(그러니까 예전처럼 Personal Setting을 찾아 해매다가 개삽질을 했다는 소린데, 요로코롬 직관적인 인터페이스로 변경되었다.)

 

1. 

첫번째로 All Workspace 에 접근하는 것은 똑같다. 다만 이후의 프로세스가 좀 다르다

 

2.

새롭게 바뀐 Persnoal settings 의 위치

이렇게 생긴 곳에서 "Personal Bitbucket settings" 로 들어가면 된다. 예전과 어떻게 달라졌는지 그림으로 알아보자

 

 

바뀌기 전의 Personal settings 의 위치

 

 

3.

어쨋든 들어가면 기존의 BitBucket 에서 사용하던 것처럼 쉽게 ssh-key 를 등록할 수 있다.

key 관리 interface 가 아무래도 Git 을 좀 따라가지 않았나 싶은 냄새가 스물스물

세션 풀림 문제 중 가장 중요한 것 하나는 Android Side - Back-end Side - Godomall 로 이어지는 연계순서였다.

중간에 이 과정에서 Spring 에서 "Bearer " 에 대한 String 을 떼어버리고 파싱한 뒤에 Godomall 쪽에 이어지는 순서로 접근하게 되는데, 이 과정에서 다시 한 번 Session Connection 이 이루어질 수 있었다.

 

자 그러면 본론으로 돌아가서 왜 한번의 Session 발급 이후에 Session 이 풀리고나서 로그인하기 힘들었던 이유가 있었는지 생각해보자

 

 

1. 

Moyamo Android Side run - init - Shop request 

이 순서상에서 이루어질 때, 앱을 처음 실행한 사용자라던가 캐시가 없는 사용자라면 해당하는 부분에 대해서 다시금 Session Sync 가 이루어졌어야 하기 때문에 한번의 연결은 정상적으로 작동하게 된다.

 

다만 그 이후에 refresh Token 이라던지 access Token 이 들어왔을 때에 주기적으로 돌아야 하는게 없었기 때문이다.

- 물론 이 부분에 대해서 찾아보면 refresh Token 이나 access Token 에 대한 로직이 있을지라도 활성 사용자수인 25만명에비하여 실사용자는 5~7만명에 그칠 것이기에 데이터베이스에서 직접 긁어다가 작동시키는 부분은 생각보다 비효율적인 트래픽을 야기할 수 있다.

 

2.

그렇다면 어차피 끊긴 김에 User의 Shop Profile 을 확인하는 End-Point 를 호출해서 소환하는 구조로 간다.

- 이 경우 Android 사이드에서 앱이 켜질때마다 request 를 날려주는 번거로움이 있긴 하지만 적어도 Session 에 대한 안정성은 보장할 수 있다. 따라서 Web-View 상에서 불러오는 쿠키의 Session 에 대해서도 변함없이 사용자가 서비스를 지속적으로 이용하게 해줄 수 있다.

 

따라서 이번엔 2번으로 접근하는 것을 유도해보고, 1번은 별도의 분석에 들어가기로 했다.

"Difference between process and thread" is one of the widely asked questions of technical interviews. Both processes and threads are related to each other and very much similar, hence create confusion to understand the differences between both of them. The process and thread are an independent sequence of execution, but both are differentiated in a way that processes execute in different memory spaces, whereas threads of the same process execute in shared memory space.

In this topic, we will understand the brief introduction of processes and threads and what are other differences between both of them.

What is Process?

A process is an instance of a program that is being executed. When we run a program, it does not execute directly. It takes some time to follow all the steps required to execute the program, and following these execution steps is known as a process.

 
 

A process can create other processes to perform multiple tasks at a time; the created processes are known as clone or child process, and the main process is known as the parent process. Each process contains its own memory space and does not share it with the other processes. It is known as the active entity. A typical process remains in the below form in memory.

A process in OS can remain in any of the following states:

  • NEW: A new process is being created.
  • READY: A process is ready and waiting to be allocated to a processor.
  • RUNNING: The program is being executed.
  • WAITING: Waiting for some event to happen or occur.
  • TERMINATED: Execution finished.

How do Processes work?

When we start executing the program, the processor begins to process it. It takes the following steps:

  • Firstly, the program is loaded into the computer's memory in binary code after translation.
  • A program requires memory and other OS resources to run it. The resources such that registers, program counter(PC, Pointer), and a stack, and these resources are provided by the OS.
  • A register can have an instruction, a storage address, or other data that is required by the process.
  • The program counter maintains the track of the program sequence.
  • The stack has information on the active subroutines of a computer program.
  • A program may have different instances of it, and each instance of the running program is knowns as the individual process.

Features of Process

  • Each time we create a process, we need to make a separate system call for each process to the OS. The fork() function creates the process.
  • Each process exists within its own address or memory space.
  • Each process is independent and treated as an isolated process by the OS.
  • Processes need IPC (Inter-process Communication) in order to communicate with each other.
  • A proper synchronization between processes is not required.

What is Thread?

A thread is the subset of a process and is also known as the lightweight process. A process can have more than one thread, and these threads are managed independently by the scheduler. All the threads within one process are interrelated to each other. Threads have some common information, such as data segment, code segment, files, etc., that is shared to their peer threads. But contains its own registers, stack, and counter.

How does thread work?

As we have discussed that a thread is a subprocess or an execution unit within a process. A process can contain a single thread to multiple threads. A thread works as follows:

  • When a process starts, OS assigns the memory and resources to it. Each thread within a process shares the memory and resources of that process only.
  • Threads are mainly used to improve the processing of an application. In reality, only a single thread is executed at a time, but due to fast context switching between threads gives an illusion that threads are running parallelly.
  • If a single thread executes in a process, it is known as a single-threaded And if multiple threads execute simultaneously, then it is known as multithreading.

Types of Threads

There are two types of threads, which are:

1. User Level Thread

As the name suggests, the user-level threads are only managed by users, and the kernel does not have its information.

These are faster, easy to create and manage.

The kernel takes all these threads as a single process and handles them as one process only.

The user-level threads are implemented by user-level libraries, not by the system calls.

 

2. Kernel-Level Thread

The kernel-level threads are handled by the Operating system and managed by its kernel. These threads are slower than user-level threads because context information is managed by the kernel. To create and implement a kernel-level thread, we need to make a system call.

Features of Thread

  • Threads share data, memory, resources, files, etc., with their peer threads within a process.
  • One system call is capable of creating more than one thread.
  • Each thread has its own stack and register.
  • Threads can directly communicate with each other as they share the same address space.
  • Threads need to be synchronized in order to avoid unexpected scenarios.

Key Differences Between Process and Thread

  • A process is independent and does not contained within another process, whereas all threads are logically contained within a process.
  • Processes are heavily weighted, whereas threads are light-weighted.
  • A process can exist individually as it contains its own memory and other resources, whereas a thread cannot have its individual existence.
  • A proper synchronization between processes is not required. In contrast, threads need to be synchronized in order to avoid unexpected scenarios. *(preventing lock)
  • Processes can communicate with each other using inter-process communication only; in contrast, threads can directly communicate with each other as they share the same address space.

Difference Table Between Process and Thread

ProcessThread

A process is an instance of a program that is being executed or processed. Thread is a segment of a process or a lightweight process that is managed by the scheduler independently.
Processes are independent of each other and hence don't share a memory or other resources. Threads are interdependent and share memory.
Each process is treated as a new process by the operating system. The operating system takes all the user-level threads as a single process.
If one process gets blocked by the operating system, then the other process can continue the execution. If any user-level thread gets blocked, all of its peer threads also get blocked because OS takes all of them as a single process.
Context switching between two processes takes much time as they are heavy compared to thread. Context switching between the threads is fast because they are very lightweight.
The data segment and code segment of each process are independent of the other. Threads share data segment and code segment with their peer threads; hence are the same for other threads also.
The operating system takes more time to terminate a process. Threads can be terminated in very little time.
New process creation is more time taking as each new process takes all the resources. A thread needs less time for creation.

 

+ Recent posts